inherited fmPrintDoc: TfmPrintDoc
  Caption = #1055#1077#1095#1072#1090#1100' '#1076#1086#1082#1091#1084#1077#1085#1090#1086#1074
  ClientHeight = 506
  ClientWidth = 472
  OnShow = FormShow
  ExplicitWidth = 480
  ExplicitHeight = 540
  PixelsPerInch = 96
  TextHeight = 13
  inherited sbBottom: TStatusBar
    Top = 479
    Width = 472
    ExplicitTop = 479
    ExplicitWidth = 472
  end
  inherited Panel1: TPanel
    Top = 434
    Width = 472
    ExplicitTop = 434
    ExplicitWidth = 472
  end
  object Panel2: TPanel [2]
    Left = 0
    Top = 0
    Width = 472
    Height = 41
    Align = alTop
    BevelInner = bvLowered
    Enabled = False
    Font.Charset = RUSSIAN_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentFont = False
    TabOrder = 2
    object edDealNo: TLabeledEdit
      Left = 75
      Top = 8
      Width = 121
      Height = 21
      TabStop = False
      BevelInner = bvLowered
      BevelKind = bkTile
      BevelOuter = bvRaised
      BorderStyle = bsNone
      EditLabel.Width = 70
      EditLabel.Height = 16
      EditLabel.Caption = ' '#1057#1076#1077#1083#1082#1072' '#8470':'
      EditLabel.Font.Charset = RUSSIAN_CHARSET
      EditLabel.Font.Color = clNavy
      EditLabel.Font.Height = -13
      EditLabel.Font.Name = 'Tahoma'
      EditLabel.Font.Style = []
      EditLabel.ParentFont = False
      LabelPosition = lpLeft
      TabOrder = 0
    end
  end
  object Panel3: TPanel [3]
    Left = 0
    Top = 41
    Width = 472
    Height = 393
    Align = alClient
    BevelInner = bvLowered
    TabOrder = 3
    object Label1: TLabel
      Left = 16
      Top = 8
      Width = 90
      Height = 13
      Caption = #1044#1072#1090#1072' '#1076#1086#1082#1091#1084#1077#1085#1090#1086#1074
      Font.Charset = RUSSIAN_CHARSET
      Font.Color = clNavy
      Font.Height = -11
      Font.Name = 'Tahoma'
      Font.Style = []
      ParentFont = False
    end
    object btnInvoice: TButton
      Left = 16
      Top = 131
      Width = 65
      Height = 25
      Caption = #1057#1095#1105#1090
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = [fsBold]
      ParentFont = False
      TabOrder = 0
      OnClick = btnInvoiceClick
    end
    object btnFactura: TButton
      Left = 80
      Top = 131
      Width = 65
      Height = 25
      Caption = #1057#1060
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = [fsBold]
      ParentFont = False
      TabOrder = 1
      OnClick = btnFacturaClick
    end
    object btnTicket: TButton
      Left = 16
      Top = 163
      Width = 65
      Height = 25
      Caption = #1050#1074#1080#1090'.'
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = [fsBold]
      ParentFont = False
      TabOrder = 2
    end
    object rgPayer: TRadioGroup
      Left = 49
      Top = 48
      Width = 122
      Height = 77
      Caption = ' '#1055#1083#1072#1090#1077#1083#1100#1097#1080#1082' '
      Font.Charset = RUSSIAN_CHARSET
      Font.Color = clNavy
      Font.Height = -11
      Font.Name = 'Tahoma'
      Font.Style = []
      Items.Strings = (
        #1054#1090#1087#1088#1072#1074#1080#1090#1077#1083#1100
        #1055#1086#1083#1091#1095#1072#1090#1077#1083#1100
        '3-'#1077' '#1083#1080#1094#1086)
      ParentFont = False
      TabOrder = 3
      OnClick = rgPayerClick
    end
    object dtDate: TDateTimePicker
      Left = 16
      Top = 24
      Width = 89
      Height = 21
      Date = 37748.000000000000000000
      Time = 37748.000000000000000000
      TabOrder = 4
    end
    object btnFacturaS: TButton
      Left = 144
      Top = 131
      Width = 65
      Height = 25
      Caption = #1057#1060'('#1057')'
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = [fsBold]
      ParentFont = False
      TabOrder = 5
      OnClick = btnFacturaSClick
    end
    object btnAct: TButton
      Left = 80
      Top = 163
      Width = 65
      Height = 25
      Caption = #1040#1082#1090
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = [fsBold]
      ParentFont = False
      TabOrder = 6
    end
    object btnActS: TButton
      Left = 144
      Top = 163
      Width = 65
      Height = 25
      Caption = #1040#1082#1090'(C)'
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = [fsBold]
      ParentFont = False
      TabOrder = 7
    end
    object cbPDF: TCheckBox
      Left = 112
      Top = 25
      Width = 97
      Height = 17
      Alignment = taLeftJustify
      Caption = #1055#1077#1095#1072#1090#1100' '#1074' PDF'
      Font.Charset = RUSSIAN_CHARSET
      Font.Color = clNavy
      Font.Height = -11
      Font.Name = 'Tahoma'
      Font.Style = []
      ParentFont = False
      TabOrder = 8
      OnClick = cbPDFClick
    end
    object btnTN: TButton
      Left = 16
      Top = 194
      Width = 193
      Height = 25
      Caption = #1055#1086#1088#1091#1095#1077#1085#1080#1077' '#1101#1082#1089#1087#1077#1076#1080#1090#1086#1088#1091
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = [fsBold]
      ParentFont = False
      TabOrder = 9
    end
  end
  inherited dlgDS: TDataSource
    Left = 432
    Top = 8
  end
  object qBlid: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT DI.OBID'
      '  FROM DEALS D'
      '   INNER JOIN CLIENTS C ON C.CLID ='
      '   CASE :Payer'
      '   WHEN 0 THEN D.DECLID_S'
      '   WHEN 1 THEN D.DECLID_R'
      '   WHEN 2 THEN D.DECLID_3'
      '   END'
      
        '   INNER JOIN DEINVOICE DI ON DI.DEID = D.DEID AND DI.CLID = C.C' +
        'LID'
      ' WHERE D.DEID = :DEID')
    Left = 40
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'PAYER'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end>
    object qBlidOBID: TIntegerField
      FieldName = 'OBID'
      Origin = '"DEINVOICE"."OBID"'
    end
  end
  object qCheckBPZD: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT D.DEID'
      '  FROM DEALS D, TRANSPORTATION T'
      ' WHERE D.DEID = :DEID'
      '   AND D.DEID = T.DEID'
      '   AND T.TSID = 5'
      '   AND (EXISTS(SELECT C.DEID'
      '                 FROM CAPTURES C'
      '                WHERE C.CAPAYCAPTURE = :PAYER'
      '                  AND D.DEID = C.DEID'
      '                  AND C.ATID = 100)'
      '        OR'
      '        EXISTS(SELECT DV.DEID'
      '                 FROM DELIVERY DV'
      '                WHERE DV.DVPAYDELIVERY = :PAYER'
      '                  AND D.DEID = DV.DEID'
      '                  AND DV.ATID = 100)'
      '       )')
    Top = 32
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'PAYER'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'PAYER'
        ParamType = ptInput
      end>
  end
  object RvNDRWriter1: TRvNDRWriter
    StatusFormat = 'Printing page %p'
    UnitsFactor = 1.000000000000000000
    Title = 'Rave Report'
    Orientation = poPortrait
    ScaleX = 100.000000000000000000
    ScaleY = 100.000000000000000000
    StreamMode = smUser
    OnPrint = RvNDRWriter1Print
    Left = 248
    Top = 9
  end
  object RvRenderPrinter1: TRvRenderPrinter
    Active = True
    DisplayName = 'RPRender'
    FileExtension = '*.ndr'
    Left = 248
    Top = 49
  end
  object qCons_R: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT CCL.CTID, CCL.CCDATE, CCL.CCISBILL'
      '       FROM DEALS D'
      
        '       JOIN BILLS B ON B.BLID = COALESCE(D.BLIDDEST, D.DEOFIDDES' +
        'T)'
      
        '       JOIN M_CUSTCROS CC ON CC.CLID = D.DECLIDRECIPIENT AND CC.' +
        'OFID = D.DEOFIDDEST'
      
        '       JOIN M_CONS_CLIENTS CCL ON CCL.CTID = CC.CTID AND CCL.OFI' +
        'D = D.DEOFIDDEST'
      '       WHERE D.DEID = :DEID AND B.BLISNDS = 0')
    Left = 216
    Top = 169
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end>
    object IntegerField1: TIntegerField
      FieldName = 'CTID'
      Origin = '"M_CONS_CLIENTS"."CTID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object qCons_RCCDATE: TDateField
      FieldName = 'CCDATE'
      Origin = '"M_CONS_CLIENTS"."CCDATE"'
    end
    object qCons_RCCISBILL: TIntegerField
      FieldName = 'CCISBILL'
      Origin = '"M_CONS_CLIENTS"."CCISBILL"'
    end
  end
  object qCons_S: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT CCL.CTID,  CCL.CCDATE, CCL.CCISBILL'
      '       FROM DEALS D'
      
        '       JOIN BILLS B ON B.BLID = COALESCE(D.BLIDSEND, D.DEOFIDSEN' +
        'D)'
      
        '       JOIN M_CUSTCROS CC ON CC.CLID = D.DECLIDSENDER AND CC.OFI' +
        'D = D.DEOFIDSEND'
      
        '       JOIN M_CONS_CLIENTS CCL ON CCL.CTID = CC.CTID AND CCL.OFI' +
        'D = D.DEOFIDSEND'
      '       WHERE D.DEID = :DEID AND B.BLISNDS = 0')
    Left = 216
    Top = 137
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end>
    object qCons_SCTID: TIntegerField
      FieldName = 'CTID'
      Origin = '"M_CONS_CLIENTS"."CTID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object qCons_SCCDATE: TDateField
      FieldName = 'CCDATE'
      Origin = '"M_CONS_CLIENTS"."CCDATE"'
    end
    object qCons_SCCISBILL: TIntegerField
      FieldName = 'CCISBILL'
      Origin = '"M_CONS_CLIENTS"."CCISBILL"'
    end
  end
  object qCRM_S: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT C.CTISPRINT'
      '       FROM DEALS D'
      
        '       JOIN M_CUSTCROS CC ON CC.CLID = D.DECLIDSENDER AND CC.OFI' +
        'D = D.DEOFIDSEND'
      
        '       JOIN M_CUSTOMER C ON C.CTID = CC.CTID AND C.OFID = D.DEOF' +
        'IDSEND'
      '       WHERE D.DEID = :DEID')
    Left = 248
    Top = 137
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end>
    object qCRM_SCTISPRINT: TIBStringField
      FieldName = 'CTISPRINT'
      Origin = '"M_CUSTOMER"."CTISPRINT"'
      Size = 1
    end
  end
  object qCRM_R: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT C.CTISPRINT'
      '       FROM DEALS D'
      
        '       JOIN M_CUSTCROS CC ON CC.CLID = D.DECLIDRECIPIENT AND CC.' +
        'OFID = D.DEOFIDDEST'
      
        '       JOIN M_CUSTOMER C ON C.CTID = CC.CTID AND C.OFID = D.DEOF' +
        'IDDEST'
      '       WHERE D.DEID = :DEID')
    Left = 248
    Top = 169
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end>
    object qCRM_RCTISPRINT: TIBStringField
      FieldName = 'CTISPRINT'
      Origin = '"M_CUSTOMER"."CTISPRINT"'
      Size = 1
    end
  end
  object qRINN: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT C.CLINN, C.CLSTATUS'
      'FROM DEALS D'
      'JOIN CLIENTS C ON C.CLID = D.DECLIDRECIPIENT'
      'WHERE D.DEID = :DEID')
    Left = 280
    Top = 137
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end>
    object qRINNCLINN: TIBStringField
      FieldName = 'CLINN'
      Origin = '"CLIENTS"."CLINN"'
      Size = 12
    end
    object qRINNCLSTATUS: TIBStringField
      FieldName = 'CLSTATUS'
      Origin = '"CLIENTS"."CLSTATUS"'
      Size = 1
    end
  end
  object rvdsTN: TRvDataSetConnection
    LocalFilter = False
    RuntimeVisibility = rtEndUser
    DataSet = qTN
    Left = 272
    Top = 96
  end
  object qTN: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT D.DEDEALNO,'
      '       CAST(D.DEDATEINSEND AS DATE) AS DEDATEINSEND1,'
      
        '       (CASE WHEN AG.MANUMBER IS NOT NULL THEN '#39#1044#1086#1075#1086#1074#1086#1088' '#8470' '#39'||AG.' +
        'MANUMBER ELSE NULL END) AS dogovor ,'
      '       OS.OFTOWN AS punkt_otpr, OD.OFTOWN AS punkt_nazn,'
      
        '       COALESCE(CLSEND.CLLEGALNAME, CLSEND.CLNAME) AS otpravitel' +
        ', CLSEND.CLPHONEWAREHOUSE1 AS phone_otpr, CLSEND.CLADDRESSWAREHO' +
        'USE AS adress_otpr,'
      '       COALESCE(CLSEND.CLLEGALNAME, CLSEND.CLNAME) AS klient,'
      
        '       COALESCE(CLDEST.CLLEGALNAME, CLDEST.CLNAME) AS poluchatel' +
        ', CLDEST.CLPHONEWAREHOUSE1 AS phone_pol, CLDEST.CLADDRESSWAREHOU' +
        'SE AS adress_pol,'
      
        '       (SELECT eks_name FROM EKSPEDITOR(:DEID)) AS eks_name, (SE' +
        'LECT eks_phone FROM EKSPEDITOR(:DEID)) as eks_phone,'
      '       (SELECT eks_adress FROM EKSPEDITOR(:DEID)) AS eks_adress,'
      '       T.TPGOODSDESCR AS xarakter_gr,'
      '       '#39#1086#1090#1087#1088#1072#1074'.'#39' usl_transp,'
      '       CASE WHEN CA.CAPAYCAPTURE IS NOT NULL THEN'
      
        '       (CASE WHEN CA.CAPAYCAPTURE = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083 +
        #1091#1095'.'#39' END)'
      '       END  AS usl_zabor,'
      '       CASE WHEN DE.DVPAYDELIVERY IS NOT NULL THEN'
      
        '       (CASE WHEN DE.DVPAYDELIVERY = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086 +
        #1083#1091#1095'.'#39' END)'
      '       END  AS usl_dost,'
      
        '       (CASE WHEN PA.PTNAME <> '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' END' +
        ')  AS usl_ju,'
      
        '       (CASE WHEN (T.TPVSTDSOFTPACK + T.TPVNOTSTDSOFTPACK) > 0.0' +
        '0 THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE NULL END)  AS usl_mu,'
      '       CASE WHEN A.ASPAYER IS NOT NULL THEN'
      
        '       (CASE WHEN A.ASPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_plomb,'
      '       CASE WHEN I.IRPAYER IS NOT NULL THEN'
      
        '       (CASE WHEN I.IRPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_vnutrit,'
      
        '       CASE WHEN ((R.RTPAYER IS NOT NULL) AND (R.RTTYPE = 2)) TH' +
        'EN'
      
        '       (CASE WHEN R.RTPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_vozvr_torg12,'
      
        '       CASE WHEN ((R.RTPAYER IS NOT NULL) AND (R.RTTYPE = 1)) TH' +
        'EN'
      
        '       (CASE WHEN R.RTPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_vozvr_email,'
      
        '       CASE WHEN (S.SS_S_PHONE IS NOT NULL) THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' END  ' +
        'AS usl_sms_otpr,'
      
        '       CASE WHEN (S.SS_D_PHONE IS NOT NULL) THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' END  ' +
        'AS usl_sms_poluch,'
      '       CASE WHEN IR.ICPAYINSURANCE IS NOT NULL THEN'
      
        '       (CASE WHEN IR.ICPAYINSURANCE = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087 +
        #1086#1083#1091#1095'.'#39' END)'
      '       END  AS usl_strax,'
      
        '       T.TPDOPINF,  T.TPMARKING, T.TPSMALLPIECECNT, T.TPSTDWEIGH' +
        'T, T.TPNOTSTDWEIGHT,'
      '       (T.TPSTDWEIGHT + T.TPNOTSTDWEIGHT) AS ves,'
      
        '       T.TPSTDVOLUME, T.TPNOTSTDVOLUME, (T.TPSTDVOLUME + T.TPNOT' +
        'STDVOLUME) AS volume,'
      '       T.TPMAXLENGTH, T.TPMAXHEIGHT, A.ASSEALSCNT,'
      
        '       (CASE WHEN A.ASSEALSCNT IS NOT NULL THEN A.ASITEMS ELSE '#39 +
        #1053#1077' '#1091#1089#1090#1072#1085#1086#1074#1083#1077#1085#1099#39' END) AS nom_plomb,'
      
        '       IIF(:is21vek = 1,(SELECT eks_name FROM EKSPEDITOR(:DEID))' +
        ',OS.OFNAME) AS gruz_prinyal,'
      
        '       (CASE WHEN ((T.TPCONDPACK IS NULL) OR (T.TPCONDPACK = 0))' +
        ' THEN '#39#1042' '#1085#1086#1088#1084#1077#39
      '             WHEN T.TPCONDPACK = 1 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080#39
      '             WHEN T.TPCONDPACK = 2 THEN '#39#1053#1077#1085#1072#1076#1083#1077#1078#1072#1097#1072#1103#39
      '             WHEN T.TPCONDPACK = 3 THEN '#39#1055#1086#1074#1088#1077#1078#1076#1077#1085#1072#39
      
        '             WHEN T.TPCONDPACK = 4 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080' '#1080' '#1085#1077#1085#1072#1076#1083#1077#1078 +
        #1072#1097#1072#1103#39
      
        '             WHEN T.TPCONDPACK = 5 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080' '#1080' '#1087#1086#1074#1088#1077#1078#1076#1077 +
        #1085#1072#39
      
        '             WHEN T.TPCONDPACK = 6 THEN '#39#1055#1086#1074#1088#1077#1078#1076#1077#1085#1072' '#1080' '#1085#1077#1085#1072#1076#1083#1077#1078#1072#1097 +
        #1072#1103#39
      
        '             WHEN T.TPCONDPACK = 7 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082'., '#1087#1086#1074#1088#1077#1078#1076#1077#1085#1072' '#1080 +
        ' '#1085#1077#1085#1072#1076#1083#1077#1078#1072#1097#1072#1103#39
      '        END) AS upak_klienta,'
      
        '       CAST((CASE WHEN T.TPISPALLET = 1 THEN '#39#1055#1086#1076#1076#1086#1085' '#1082#1083#1080#1077#1085#1090#1072' '#39' E' +
        'LSE '#39#39' END)||'
      
        '       (CASE WHEN (T.TPVSTDSOFTPACK + T.TPVNOTSTDSOFTPACK) > 0.0' +
        '0 THEN '#39#1052#1059' '#39' ELSE '#39#39' END)||'
      
        '       (CASE WHEN PA.PTNAME <> '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080#39' THEN '#39#1046#1059' '#39' ELSE '#39#39 +
        ' END)'
      '       AS VARCHAR(50)'
      '       ) AS vid_upakovki,'
      
        '       CAST((CASE WHEN PA.PTNAME <> '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080#39' THEN PA.PTNAM' +
        'E END) AS VARCHAR(5)) AS vid_ju,'
      
        '       T.TPSTDVNOTPACKING, T.TPSTDVPACKING, T.TPNOTSTDVNOTPACKIN' +
        'G, T.TPNOTSTDVPACKING'
      'FROM DEALS D'
      'INNER JOIN TRANSPORTATION T ON T.DEID = D.DEID'
      'INNER JOIN CLIENTS CLSEND ON CLSEND.CLID = D.DECLIDSENDER'
      'INNER JOIN CLIENTS CLDEST ON CLDEST.CLID = D.DECLIDRECIPIENT'
      'INNER JOIN OFFICES OS ON OS.OFID = D.DEOFIDSEND'
      'INNER JOIN OFFICES OD ON OD.OFID = D.DEOFIDDEST'
      'LEFT OUTER JOIN CAPTURES CA ON CA.DEID = D.DEID'
      'LEFT OUTER JOIN DELIVERY DE ON DE.DEID = D.DEID'
      'LEFT OUTER JOIN PACKINGTYPES PA ON PA.PTID = T.PTID'
      'LEFT OUTER JOIN ADDSERVICE A ON A.DEID = D.DEID'
      'LEFT OUTER JOIN INTARE I ON I.DEID = D.DEID'
      'LEFT OUTER JOIN RETURNDOC R ON R.DEID = D.DEID'
      'LEFT OUTER JOIN SMS S ON S.DEID = D.DEID'
      
        'LEFT OUTER JOIN M_CUSTCROS MC ON MC.CLID = D.DECLIDSENDER AND MC' +
        '.OFID = :OFID'
      
        'LEFT OUTER JOIN M_AGREEMENTS AG ON AG.CTID = MC.CTID AND AG.OFID' +
        ' = :OFID'
      
        '                AND D.DEDATEINSEND BETWEEN AG.MABEGIN AND AG.MAE' +
        'ND AND AG.TYPE_AGREE = 260'
      'LEFT OUTER JOIN INSURANCE IR ON IR.DEID = D.DEID'
      'WHERE D.DEID = :DEID'
      '      AND T.TPPAYTRANSPORTATION = '#39'0'#39
      'UNION'
      
        'SELECT D.DEDEALNO, CAST(D.DEDATEINSEND AS DATE) AS DEDATEINSEND1' +
        ','
      
        '       (CASE WHEN AG.MANUMBER IS NOT NULL THEN '#39#1044#1086#1075#1086#1074#1086#1088' '#8470' '#39'||AG.' +
        'MANUMBER ELSE NULL END) AS dogovor ,'
      '       OS.OFTOWN AS punkt_otpr, OD.OFTOWN AS punkt_nazn,'
      
        '       COALESCE(CLSEND.CLLEGALNAME, CLSEND.CLNAME) AS otpravitel' +
        ', CLSEND.CLPHONEWAREHOUSE1 AS phone_otpr, CLSEND.CLADDRESSWAREHO' +
        'USE AS adress_otpr,'
      '       COALESCE(CLDEST.CLLEGALNAME, CLDEST.CLNAME) AS klient,'
      
        '       COALESCE(CLDEST.CLLEGALNAME, CLDEST.CLNAME) AS poluchatel' +
        ', CLDEST.CLPHONEWAREHOUSE1  AS phone_pol, CLDEST.CLADDRESSWAREHO' +
        'USE AS adress_pol,'
      
        '       (SELECT eks_name FROM EKSPEDITOR(:DEID)) AS eks_name, (SE' +
        'LECT eks_phone FROM EKSPEDITOR(:DEID)) as eks_phone,'
      '       (SELECT eks_adress FROM EKSPEDITOR(:DEID)) AS eks_adress,'
      '       T.TPGOODSDESCR AS xarakter_gr,'
      '       '#39#1087#1086#1083#1091#1095'.'#39' usl_transp,'
      '       CASE WHEN CA.CAPAYCAPTURE IS NOT NULL THEN'
      
        '       (CASE WHEN CA.CAPAYCAPTURE = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083 +
        #1091#1095'.'#39' END)'
      '       END  AS usl_zabor,'
      '       CASE WHEN DE.DVPAYDELIVERY IS NOT NULL THEN'
      
        '       (CASE WHEN DE.DVPAYDELIVERY = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086 +
        #1083#1091#1095'.'#39' END)'
      '       END  AS usl_dost,'
      
        '       (CASE WHEN PA.PTNAME <> '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080#39' THEN '#39#1087#1086#1083#1091#1095'.'#39' END)' +
        '  AS usl_ju,'
      
        '       (CASE WHEN (T.TPVSTDSOFTPACK + T.TPVNOTSTDSOFTPACK) > 0.0' +
        '0 THEN '#39#1087#1086#1083#1091#1095'.'#39' ELSE NULL END)  AS usl_mu,'
      '       CASE WHEN A.ASPAYER IS NOT NULL THEN'
      
        '       (CASE WHEN A.ASPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_plomb,'
      '       CASE WHEN I.IRPAYER IS NOT NULL THEN'
      
        '       (CASE WHEN I.IRPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_vnutrit,'
      
        '       CASE WHEN ((R.RTPAYER IS NOT NULL) AND (R.RTTYPE = 2)) TH' +
        'EN'
      
        '       (CASE WHEN R.RTPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_vozvr_torg12,'
      
        '       CASE WHEN ((R.RTPAYER IS NOT NULL) AND (R.RTTYPE = 1)) TH' +
        'EN'
      
        '       (CASE WHEN R.RTPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_vozvr_email,'
      
        '       CASE WHEN (S.SS_S_PHONE IS NOT NULL) THEN '#39#1087#1086#1083#1091#1095'.'#39' END  A' +
        'S usl_sms_otpr,'
      
        '       CASE WHEN (S.SS_D_PHONE IS NOT NULL) THEN '#39#1087#1086#1083#1091#1095'.'#39' END  A' +
        'S usl_sms_poluch,'
      '       CASE WHEN IR.ICPAYINSURANCE IS NOT NULL THEN'
      
        '       (CASE WHEN IR.ICPAYINSURANCE = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087 +
        #1086#1083#1091#1095'.'#39' END)'
      '       END  AS usl_strax,'
      
        '       T.TPDOPINF,  T.TPMARKING, T.TPSMALLPIECECNT, T.TPSTDWEIGH' +
        'T, T.TPNOTSTDWEIGHT,'
      '       (T.TPSTDWEIGHT + T.TPNOTSTDWEIGHT) AS ves,'
      
        '       T.TPSTDVOLUME, T.TPNOTSTDVOLUME, (T.TPSTDVOLUME + T.TPNOT' +
        'STDVOLUME) AS volume,'
      '       T.TPMAXLENGTH, T.TPMAXHEIGHT, A.ASSEALSCNT,'
      
        '       (CASE WHEN A.ASSEALSCNT IS NOT NULL THEN A.ASITEMS ELSE '#39 +
        #1053#1077' '#1091#1089#1090#1072#1085#1086#1074#1083#1077#1085#1099#39' END) AS nom_plomb,'
      
        '       IIF(:is21vek = 1,(SELECT eks_name FROM EKSPEDITOR(:DEID))' +
        ',OS.OFNAME) AS gruz_prinyal,'
      
        '       (CASE WHEN ((T.TPCONDPACK IS NULL) OR (T.TPCONDPACK = 0))' +
        ' THEN '#39#1042' '#1085#1086#1088#1084#1077#39
      '             WHEN T.TPCONDPACK = 1 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080#39
      '             WHEN T.TPCONDPACK = 2 THEN '#39#1053#1077#1085#1072#1076#1083#1077#1078#1072#1097#1072#1103#39
      '             WHEN T.TPCONDPACK = 3 THEN '#39#1055#1086#1074#1088#1077#1078#1076#1077#1085#1072#39
      
        '             WHEN T.TPCONDPACK = 4 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080' '#1080' '#1085#1077#1085#1072#1076#1083#1077#1078 +
        #1072#1097#1072#1103#39
      
        '             WHEN T.TPCONDPACK = 5 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080' '#1080' '#1087#1086#1074#1088#1077#1078#1076#1077 +
        #1085#1072#39
      
        '             WHEN T.TPCONDPACK = 6 THEN '#39#1055#1086#1074#1088#1077#1078#1076#1077#1085#1072' '#1080' '#1085#1077#1085#1072#1076#1083#1077#1078#1072#1097 +
        #1072#1103#39
      
        '             WHEN T.TPCONDPACK = 7 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082'., '#1087#1086#1074#1088#1077#1078#1076#1077#1085#1072' '#1080 +
        ' '#1085#1077#1085#1072#1076#1083#1077#1078#1072#1097#1072#1103#39
      '        END) AS upak_klienta,'
      
        '       CAST((CASE WHEN T.TPISPALLET = 1 THEN '#39#1055#1086#1076#1076#1086#1085' '#1082#1083#1080#1077#1085#1090#1072' '#39' E' +
        'LSE '#39#39' END)||'
      
        '       (CASE WHEN (T.TPVSTDSOFTPACK + T.TPVNOTSTDSOFTPACK) > 0.0' +
        '0 THEN '#39#1052#1059' '#39' ELSE '#39#39' END)||'
      
        '       (CASE WHEN PA.PTNAME <> '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080#39' THEN '#39#1046#1059' '#39' ELSE '#39#39 +
        ' END)'
      '       AS VARCHAR(50)'
      '       ) AS vid_upakovki,'
      
        '       CAST((CASE WHEN PA.PTNAME <> '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080#39' THEN PA.PTNAM' +
        'E END) AS VARCHAR(5)) AS vid_ju,'
      
        '       T.TPSTDVNOTPACKING, T.TPSTDVPACKING, T.TPNOTSTDVNOTPACKIN' +
        'G, T.TPNOTSTDVPACKING'
      'FROM DEALS D'
      'INNER JOIN TRANSPORTATION T ON T.DEID = D.DEID'
      'INNER JOIN CLIENTS CLSEND ON CLSEND.CLID = D.DECLIDSENDER'
      'INNER JOIN CLIENTS CLDEST ON CLDEST.CLID = D.DECLIDRECIPIENT'
      'INNER JOIN OFFICES OS ON OS.OFID = D.DEOFIDSEND'
      'INNER JOIN OFFICES OD ON OD.OFID = D.DEOFIDDEST'
      'LEFT OUTER JOIN CAPTURES CA ON CA.DEID = D.DEID'
      'LEFT OUTER JOIN DELIVERY DE ON DE.DEID = D.DEID'
      'LEFT OUTER JOIN PACKINGTYPES PA ON PA.PTID = T.PTID'
      'LEFT OUTER JOIN ADDSERVICE A ON A.DEID = D.DEID'
      'LEFT OUTER JOIN INTARE I ON I.DEID = D.DEID'
      'LEFT OUTER JOIN RETURNDOC R ON R.DEID = D.DEID'
      'LEFT OUTER JOIN SMS S ON S.DEID = D.DEID'
      
        'LEFT OUTER JOIN M_CUSTCROS MC ON MC.CLID = D.DECLIDRECIPIENT AND' +
        ' MC.OFID = :OFID'
      
        'LEFT OUTER JOIN M_AGREEMENTS AG ON AG.CTID = MC.CTID AND AG.OFID' +
        ' = :OFID'
      
        '                AND D.DEDATEINSEND BETWEEN AG.MABEGIN AND AG.MAE' +
        'ND AND AG.TYPE_AGREE = 260'
      'LEFT OUTER JOIN INSURANCE IR ON IR.DEID = D.DEID'
      'WHERE D.DEID = :DEID'
      '      AND T.TPPAYTRANSPORTATION = '#39'1'#39)
    Left = 248
    Top = 97
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'is21vek'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'OFID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'OFID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'is21vek'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'OFID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'OFID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end>
    object qTNDEDEALNO: TIBStringField
      FieldName = 'DEDEALNO'
      Origin = '"DEALS"."DEDEALNO"'
    end
    object qTNDOGOVOR: TIBStringField
      FieldName = 'DOGOVOR'
      ProviderFlags = []
      Size = 50
    end
    object qTNPUNKT_OTPR: TIBStringField
      FieldName = 'PUNKT_OTPR'
      Origin = '"OFFICES"."OFTOWN"'
    end
    object qTNPUNKT_NAZN: TIBStringField
      FieldName = 'PUNKT_NAZN'
      Origin = '"OFFICES"."OFTOWN"'
    end
    object qTNOTPRAVITEL: TIBStringField
      FieldName = 'OTPRAVITEL'
      Origin = '"CLIENTS"."CLNAME"'
      Size = 255
    end
    object qTNKLIENT: TIBStringField
      FieldName = 'KLIENT'
      Origin = '"CLIENTS"."CLNAME"'
      Size = 255
    end
    object qTNPOLUCHATEL: TIBStringField
      FieldName = 'POLUCHATEL'
      Origin = '"CLIENTS"."CLNAME"'
      Size = 255
    end
    object qTNEKS_NAME: TIBStringField
      FieldName = 'EKS_NAME'
      ProviderFlags = []
      Size = 255
    end
    object qTNEKS_ADRESS: TIBStringField
      FieldName = 'EKS_ADRESS'
      ProviderFlags = []
      Size = 255
    end
    object qTNXARAKTER_GR: TIBStringField
      FieldName = 'XARAKTER_GR'
      Origin = '"TRANSPORTATION"."TPGOODSDESCR"'
      Size = 255
    end
    object qTNUSL_TRANSP: TIBStringField
      FieldName = 'USL_TRANSP'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qTNUSL_ZABOR: TIBStringField
      FieldName = 'USL_ZABOR'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qTNUSL_DOST: TIBStringField
      FieldName = 'USL_DOST'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qTNUSL_JU: TIBStringField
      FieldName = 'USL_JU'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qTNUSL_MU: TIBStringField
      FieldName = 'USL_MU'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qTNUSL_PLOMB: TIBStringField
      FieldName = 'USL_PLOMB'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qTNUSL_VNUTRIT: TIBStringField
      FieldName = 'USL_VNUTRIT'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qTNUSL_VOZVR_TORG12: TIBStringField
      FieldName = 'USL_VOZVR_TORG12'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qTNUSL_VOZVR_EMAIL: TIBStringField
      FieldName = 'USL_VOZVR_EMAIL'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qTNUSL_SMS_OTPR: TIBStringField
      FieldName = 'USL_SMS_OTPR'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qTNUSL_SMS_POLUCH: TIBStringField
      FieldName = 'USL_SMS_POLUCH'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qTNUSL_STRAX: TIBStringField
      FieldName = 'USL_STRAX'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qTNTPDOPINF: TIBStringField
      FieldName = 'TPDOPINF'
      Origin = '"TRANSPORTATION"."TPDOPINF"'
      Size = 100
    end
    object qTNTPMARKING: TIBStringField
      FieldName = 'TPMARKING'
      Origin = '"TRANSPORTATION"."TPMARKING"'
      Size = 30
    end
    object qTNTPSMALLPIECECNT: TIntegerField
      FieldName = 'TPSMALLPIECECNT'
      Origin = '"TRANSPORTATION"."TPSMALLPIECECNT"'
    end
    object qTNTPMAXLENGTH: TFloatField
      FieldName = 'TPMAXLENGTH'
      Origin = '"TRANSPORTATION"."TPMAXLENGTH"'
    end
    object qTNTPMAXHEIGHT: TFloatField
      FieldName = 'TPMAXHEIGHT'
      Origin = '"TRANSPORTATION"."TPMAXHEIGHT"'
    end
    object qTNASSEALSCNT: TIntegerField
      FieldName = 'ASSEALSCNT'
      Origin = '"ADDSERVICE"."ASSEALSCNT"'
    end
    object qTNNOM_PLOMB: TIBStringField
      FieldName = 'NOM_PLOMB'
      ProviderFlags = []
      Size = 100
    end
    object qTNGRUZ_PRINYAL: TIBStringField
      FieldName = 'GRUZ_PRINYAL'
      Origin = '"OFFICES"."OFNAME"'
      Size = 80
    end
    object qTNUPAK_KLIENTA: TIBStringField
      FieldName = 'UPAK_KLIENTA'
      ProviderFlags = []
      FixedChar = True
      Size = 36
    end
    object qTNVID_UPAKOVKI: TIBStringField
      FieldName = 'VID_UPAKOVKI'
      ProviderFlags = []
      Size = 50
    end
    object qTNVID_JU: TIBStringField
      FieldName = 'VID_JU'
      ProviderFlags = []
      Size = 5
    end
    object qTNPHONE_OTPR: TIBStringField
      FieldName = 'PHONE_OTPR'
      Origin = '"CLIENTS"."CLPHONEWAREHOUSE1"'
    end
    object qTNADRESS_OTPR: TIBStringField
      FieldName = 'ADRESS_OTPR'
      Origin = '"CLIENTS"."CLADDRESSWAREHOUSE"'
      Size = 255
    end
    object qTNPHONE_POL: TIBStringField
      FieldName = 'PHONE_POL'
      Origin = '"CLIENTS"."CLPHONEWAREHOUSE1"'
    end
    object qTNADRESS_POL: TIBStringField
      FieldName = 'ADRESS_POL'
      Origin = '"CLIENTS"."CLADDRESSWAREHOUSE"'
      Size = 255
    end
    object qTNEKS_PHONE: TIBStringField
      FieldName = 'EKS_PHONE'
      ProviderFlags = []
      Size = 255
    end
    object qTNDEDATEINSEND1: TDateField
      FieldName = 'DEDATEINSEND1'
      ProviderFlags = []
    end
    object qTNTPSTDWEIGHT: TFloatField
      FieldName = 'TPSTDWEIGHT'
      Origin = '"TRANSPORTATION"."TPSTDWEIGHT"'
    end
    object qTNTPNOTSTDWEIGHT: TFloatField
      FieldName = 'TPNOTSTDWEIGHT'
      Origin = '"TRANSPORTATION"."TPNOTSTDWEIGHT"'
    end
    object qTNTPSTDVOLUME: TFloatField
      FieldName = 'TPSTDVOLUME'
      Origin = '"TRANSPORTATION"."TPSTDVOLUME"'
    end
    object qTNTPNOTSTDVOLUME: TFloatField
      FieldName = 'TPNOTSTDVOLUME'
      Origin = '"TRANSPORTATION"."TPNOTSTDVOLUME"'
    end
    object qTNVES: TFloatField
      FieldName = 'VES'
      ProviderFlags = []
    end
    object qTNVOLUME: TFloatField
      FieldName = 'VOLUME'
      ProviderFlags = []
    end
    object qTNTPSTDVNOTPACKING: TFloatField
      FieldName = 'TPSTDVNOTPACKING'
      Origin = '"TRANSPORTATION"."TPSTDVNOTPACKING"'
    end
    object qTNTPSTDVPACKING: TFloatField
      FieldName = 'TPSTDVPACKING'
      Origin = '"TRANSPORTATION"."TPSTDVPACKING"'
    end
    object qTNTPNOTSTDVNOTPACKING: TFloatField
      FieldName = 'TPNOTSTDVNOTPACKING'
      Origin = '"TRANSPORTATION"."TPNOTSTDVNOTPACKING"'
    end
    object qTNTPNOTSTDVPACKING: TFloatField
      FieldName = 'TPNOTSTDVPACKING'
      Origin = '"TRANSPORTATION"."TPNOTSTDVPACKING"'
    end
  end
  object qBLRekvizity: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT B.BLADRESS, B.BLPHONE, B.BLFAX, B.BLEMAIL'
      'FROM DEALS D'
      'INNER JOIN BILLS B ON B.OFID = D.DEOFIDSEND'
      'WHERE B.BLISNDS = 1 AND D.DEOFIDSEND <> 1 AND D.DEID = :DEID'
      'UNION'
      'SELECT B.BLADRESS, B.BLPHONE, B.BLFAX, B.BLEMAIL'
      'FROM DEALS D'
      'INNER JOIN BILLS B ON B.OFID = D.DEOFIDSEND'
      'WHERE B.BLISNDS = 0 AND D.DEOFIDSEND = 1 AND D.DEID = :DEID')
    Left = 344
    Top = 97
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end>
    object qBLRekvizityBLADRESS: TIBStringField
      FieldName = 'BLADRESS'
      Origin = '"BILLS"."BLADRESS"'
      Size = 255
    end
    object qBLRekvizityBLPHONE: TIBStringField
      FieldName = 'BLPHONE'
      Origin = '"BILLS"."BLPHONE"'
      Size = 255
    end
    object qBLRekvizityBLFAX: TIBStringField
      FieldName = 'BLFAX'
      Origin = '"BILLS"."BLFAX"'
      Size = 255
    end
    object qBLRekvizityBLEMAIL: TIBStringField
      FieldName = 'BLEMAIL'
      Origin = '"BILLS"."BLEMAIL"'
      Size = 50
    end
  end
  object qBLRekvizity_poluch: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT B.BLADRESS, B.BLPHONE, B.BLFAX, B.BLEMAIL'
      'FROM DEALS D'
      'INNER JOIN TERMINALS T ON T.OFID = D.DEOFIDDEST'
      'INNER JOIN BILLS B ON B.OFID = T.OFMAINID'
      'WHERE B.BLISNDS = 1 AND T.OFMAINID <> 1 AND D.DEID = :DEID'
      'UNION'
      'SELECT B.BLADRESS, B.BLPHONE, B.BLFAX, B.BLEMAIL'
      'FROM DEALS D'
      'INNER JOIN TERMINALS T ON T.OFID = D.DEOFIDDEST'
      'INNER JOIN BILLS B ON B.OFID = T.OFMAINID'
      'WHERE B.BLISNDS = 0 AND T.OFMAINID = 1 AND D.DEID = :DEID')
    Left = 344
    Top = 129
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end>
    object IBStringField1: TIBStringField
      FieldName = 'BLADRESS'
      Origin = '"BILLS"."BLADRESS"'
      Size = 255
    end
    object IBStringField2: TIBStringField
      FieldName = 'BLPHONE'
      Origin = '"BILLS"."BLPHONE"'
      Size = 255
    end
    object IBStringField3: TIBStringField
      FieldName = 'BLFAX'
      Origin = '"BILLS"."BLFAX"'
      Size = 255
    end
    object IBStringField4: TIBStringField
      FieldName = 'BLEMAIL'
      Origin = '"BILLS"."BLEMAIL"'
      Size = 50
    end
  end
  object qBLRekvizity_21vek: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT B.BLADRESS, B.BLPHONE, B.BLFAX, B.BLEMAIL'
      '    FROM BILLS B '
      '    WHERE B.OFID = 1 AND'
      '          B.BLISNDS = 0 ')
    Left = 344
    Top = 161
    object IBStringField6: TIBStringField
      FieldName = 'BLADRESS'
      Origin = '"BILLS"."BLADRESS"'
      Size = 255
    end
    object IBStringField7: TIBStringField
      FieldName = 'BLPHONE'
      Origin = '"BILLS"."BLPHONE"'
      Size = 255
    end
    object IBStringField15: TIBStringField
      FieldName = 'BLFAX'
      Origin = '"BILLS"."BLFAX"'
      Size = 255
    end
    object IBStringField16: TIBStringField
      FieldName = 'BLEMAIL'
      Origin = '"BILLS"."BLEMAIL"'
      Size = 50
    end
  end
  object rvdsRekvizity: TRvDataSetConnection
    LocalFilter = False
    RuntimeVisibility = rtEndUser
    DataSet = qBLRekvizity
    Left = 368
    Top = 96
  end
  object qIs21vek: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT is21, eks_name FROM EKSPEDITOR(:DEID)')
    Left = 416
    Top = 97
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end>
    object qIs21vekIS21: TIntegerField
      FieldName = 'IS21'
      Origin = '"EKSPEDITOR"."IS21"'
    end
    object qIs21vekEKS_NAME: TIBStringField
      FieldName = 'EKS_NAME'
      Origin = '"EKSPEDITOR"."EKS_NAME"'
      Size = 255
    end
  end
  object qCaptureDate: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT CAST(DE.DEDATEINSEND AS DATE) DEDATE'
      '  FROM DEALS DE'
      'INNER JOIN DESERVICES DS ON DS.DEID = DE.DEID'
      ' WHERE DE.DEID = :DEID'
      '       AND DS.SVID = 2'
      '       AND DS.DSPAYER = :Payer'
      '       AND NOT EXISTS'
      '       (SELECT DS1.DEID'
      '          FROM DESERVICES DS1'
      '         WHERE DS1.DEID = DS.DEID'
      '               AND DS1.SVID = 1'
      '               AND DS1.DSPAYER = DS.DSPAYER)'
      '       AND NOT EXISTS'
      '       (SELECT DS2.DEID'
      '          FROM DESERVICES DS2'
      '         WHERE DS2.DEID = DS.DEID'
      '               AND DS2.SVID = 3'
      '               AND DS2.DSPAYER = DS.DSPAYER)')
    Left = 8
    Top = 265
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'Payer'
        ParamType = ptInput
      end>
    object qCaptureDateDEDATE: TDateField
      FieldName = 'DEDATE'
    end
  end
  object qMainDate: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT DE.DEDATERECIPIENT AS DEDATE'
      '  FROM DEALS DE'
      ' WHERE DE.DEID = :DEID')
    Left = 32
    Top = 265
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end>
    object qMainDateDEDATE: TDateField
      FieldName = 'DEDATE'
    end
  end
  object qCheckActSender: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT D.DEID'
      '  FROM DEALS D'
      '  LEFT OUTER JOIN CAPTURES C ON (D.DEID = C.DEID)'
      '  LEFT OUTER JOIN DELIVERY DV ON (D.DEID = DV.DEID)'
      '  LEFT OUTER JOIN INSURANCE I ON (D.DEID = I.DEID)'
      '  LEFT OUTER JOIN ADDSERVICE A ON (D.DEID = A.DEID)'
      '  LEFT OUTER JOIN INTARE IT ON (D.DEID = IT.DEID)'
      '  LEFT OUTER JOIN RETURNDOC RD ON (D.DEID = RD.DEID)'
      ' INNER JOIN TRANSPORTATION T ON (D.DEID = T.DEID)'
      ' WHERE D.DEID = :DEID'
      '   AND (C.CAPAYCAPTURE = '#39'0'#39' OR'
      '        DV.DVPAYDELIVERY = '#39'0'#39' OR'
      '        I.ICPAYINSURANCE = '#39'0'#39' OR'
      '        T.TPPAYTRANSPORTATION = '#39'0'#39' OR'
      '        A.ASPAYER = 0 OR'
      '        IT.IRPAYER = 0 OR'
      '        RD.RTPAYER = 0)')
    Left = 80
    Top = 265
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end>
  end
  object qCheckBalance: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT CAST(D.DEBALANCESENDER AS NUMERIC(15,2)) DEBALANCESENDER,'
      
        '       CAST(D.DEBALANCERECIPIENT AS NUMERIC(15,2)) DEBALANCERECI' +
        'PIENT'
      '  FROM DEALS D'
      ' WHERE D.DEID = :DEID')
    Left = 104
    Top = 265
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end>
    object qCheckBalanceDEBALANCESENDER: TIBBCDField
      FieldName = 'DEBALANCESENDER'
      ProviderFlags = []
      Precision = 18
      Size = 2
    end
    object qCheckBalanceDEBALANCERECIPIENT: TIBBCDField
      FieldName = 'DEBALANCERECIPIENT'
      ProviderFlags = []
      Precision = 18
      Size = 2
    end
  end
  object qCheckPayer: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT DS.DEID, DS.SVID,'
      '       CASE DS.DSPAYER'
      '       WHEN 1098 THEN 0'
      '       WHEN 1099 THEN 1'
      '       WHEN 1100 THEN 2'
      '       END AS DSPAYER'
      'FROM DEALS D'
      'INNER JOIN DESERVICES DS ON DS.DEID = D.DEID'
      'WHERE D.DEID = :DEID'
      'ORDER BY 2')
    Left = 128
    Top = 265
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end>
    object qCheckPayerDEID: TIntegerField
      FieldName = 'DEID'
      Origin = '"DESERVICES"."DEID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object qCheckPayerSVID: TIntegerField
      FieldName = 'SVID'
      Origin = '"DESERVICES"."SVID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object qCheckPayerDSPAYER: TIntegerField
      FieldName = 'DSPAYER'
      ProviderFlags = []
    end
  end
  object qCapNal: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT D.DEID'
      '  FROM CAPTURES C, DEALS D'
      ' WHERE D.DEID = :DEID'
      '   AND D.DEID = C.DEID'
      '   AND C.CAPAYCAPTURE = '#39'0'#39
      '   AND C.CAPAYMETHOD = '#39'0'#39
      '   AND NOT EXISTS'
      '       (SELECT T.DEID'
      '          FROM TRANSPORTATION T'
      '         WHERE T.TPPAYTRANSPORTATION = '#39'0'#39
      '           AND T.DEID = D.DEID)'
      '   AND NOT EXISTS'
      '       (SELECT DV.DEID'
      '          FROM DELIVERY DV'
      '         WHERE DV.DVPAYDELIVERY = '#39'0'#39
      '           AND DV.DEID = D.DEID)'
      '   AND NOT EXISTS'
      '       (SELECT S.DEID'
      '          FROM INSURANCE S'
      '         WHERE S.ICPAYINSURANCE = '#39'0'#39
      '           AND S.DEID = D.DEID)'
      '   AND NOT EXISTS'
      '       (SELECT A.DEID'
      '          FROM ADDSERVICE A'
      '         WHERE A.ASPAYER = 0'
      '           AND A.DEID = D.DEID)'
      '   AND NOT EXISTS'
      '       (SELECT IT.DEID'
      '          FROM INTARE IT'
      '         WHERE IT.IRPAYER = 0'
      '           AND IT.DEID = D.DEID)'
      '   AND NOT EXISTS'
      '       (SELECT RD.DEID'
      '          FROM RETURNDOC RD'
      '         WHERE RD.RTPAYER = 0'
      '           AND RD.DEID = D.DEID)')
    Left = 152
    Top = 233
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end>
  end
  object qRNal: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT D.DEID'
      '  FROM INSURANCE I'
      ' RIGHT OUTER JOIN DEALS D ON (I.DEID = D.DEID)'
      '  LEFT OUTER JOIN TRANSPORTATION T ON (D.DEID = T.DEID)'
      '  LEFT OUTER JOIN CAPTURES C ON (D.DEID = C.DEID)'
      '  LEFT OUTER JOIN DELIVERY DV ON (D.DEID = DV.DEID)'
      '  LEFT OUTER JOIN ADDSERVICE A ON (D.DEID = A.DEID)'
      '  LEFT OUTER JOIN INTARE IT ON (D.DEID = IT.DEID)'
      '  LEFT OUTER JOIN RETURNDOC RD ON (D.DEID = RD.DEID)'
      ' WHERE D.DEID = :DEID'
      '   AND ((I.ICPAYINSURANCE = '#39'1'#39' AND I.ICPAYMETHOD <> '#39'0'#39') OR'
      
        '        (T.TPPAYTRANSPORTATION = '#39'1'#39' AND T.TPPAYMETHOD <> '#39'0'#39') O' +
        'R'
      '        (C.CAPAYCAPTURE = '#39'1'#39' AND C.CAPAYMETHOD <> '#39'0'#39') OR'
      '        (DV.DVPAYDELIVERY = '#39'1'#39' AND DV.DVPAYMETHOD <> '#39'0'#39') OR'
      '        (A.ASPAYER = 1 AND A.ASPAYMETOD <> 0) OR'
      '        (IT.IRPAYER = 1 AND IT.IRPAYMETOD <> 0) OR'
      '        (RD.RTPAYER = 1 AND RD.RTPAYMETOD <> 0))')
    Left = 176
    Top = 233
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end>
  end
  object qPlat: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT D.BDNUMBER, D.BDDATE'
      '  FROM BUHCOMMON C, BUHDOCS D, DEALS DE'
      ' WHERE C.BDID = D.BDID'
      '   AND C.OFID = D.OFID'
      '   AND C.DEID = DE.DEID'
      '   AND DE.DEID = :DEID'
      '   AND C.CLID = CASE :PAYER'
      '       WHEN 0 THEN DE.DECLID_S'
      '       WHEN 1 THEN DE.DECLID_R'
      '       WHEN 2 THEN DE.DECLID_3'
      '       END'
      '   AND D.BDDATE <= :PRINTDATE')
    Left = 160
    Top = 265
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
        Value = '17892'
      end
      item
        DataType = ftInteger
        Name = 'Payer'
        ParamType = ptInput
        Value = '0'
      end
      item
        DataType = ftDate
        Name = 'PRINTDATE'
        ParamType = ptInput
      end>
    object qPlatBDNUMBER: TIBStringField
      FieldName = 'BDNUMBER'
      Origin = '"BUHDOCS"."BDNUMBER"'
    end
    object qPlatBDDATE: TDateField
      FieldName = 'BDDATE'
      Origin = '"BUHDOCS"."BDDATE"'
    end
  end
  object qInv: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      
        'SELECT D.DEID, D.DEENTERED, C.CLNAME, CS.CLNAME AS CL_send, CR.C' +
        'LNAME AS cl_res, (SELECT EKS_NAME FROM EKSPEDITOR(:DEID)) AS EKS' +
        '_NAME,'
      '       D.OFID, DI.DIAMOUNT,'
      '       DI.DINDS, DI.OBID, DI.DIID,'
      
        '       O.OCINN OFINN, OB.OBBANK OFBANK, OB.OBSETACCOUNT OFSETACC' +
        'OUNT,'
      '       OB.OBCORACCOUNT OFCORACCOUNT, OB.OBBIK OFBIK,'
      '       O.OCLEGALNAME OFNAME, O.OCKPP OFKPP,'
      '       O.OCLEGALADRESS,'
      '       O.OCEMAIL, O.OCPHONE, O.OCFAX, O.OCADRESS,'
      '       O.OCNDS,'
      '       DI.DIBALANCE DEBALANCE,'
      '       OS.OFTOWN AS townsend, OD.OFTOWN AS towdest'
      'FROM DEALS D'
      '   INNER JOIN CLIENTS C ON C.CLID ='
      '   CASE :Payer'
      '        WHEN 1098 THEN D.DECLID_S'
      '        WHEN 1099 THEN D.DECLID_R'
      '        WHEN 1100 THEN D.DECLID_3'
      '   END'
      
        '   INNER JOIN DEINVOICE DI ON DI.DEID = D.DEID AND DI.CLID = C.C' +
        'LID'
      '   INNER JOIN OFCOMPANIES O ON O.OFID = DI.OBID'
      
        '   INNER JOIN OFFBILLS OB ON OB.OBID = O.OCMAINBILL AND OB.OBACT' +
        'IVE = 1'
      '   INNER JOIN CLIENTS CS ON CS.CLID = D.DECLID_S'
      '   INNER JOIN CLIENTS CR ON CR.CLID = D.DECLID_R'
      '   INNER JOIN OFFICES OS ON OS.OFID = D.DEOFIDSEND'
      '   INNER JOIN OFFICES OD ON OD.OFID = D.DEOFIDDEST'
      'WHERE D.DEID = :DEID')
    Left = 8
    Top = 297
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
        Value = '85443'
      end
      item
        DataType = ftUnknown
        Name = 'Payer'
        ParamType = ptUnknown
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end>
    object qInvDEID: TIntegerField
      FieldName = 'DEID'
      Origin = '"DEALS"."DEID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object qInvDEENTERED: TDateTimeField
      FieldName = 'DEENTERED'
      Origin = '"DEALS"."DEENTERED"'
    end
    object qInvCLNAME: TIBStringField
      FieldName = 'CLNAME'
      Origin = '"CLIENTS"."CLNAME"'
      Size = 255
    end
    object qInvOFID: TIntegerField
      FieldName = 'OFID'
      Origin = '"DEALS"."OFID"'
    end
    object qInvDIAMOUNT: TIBBCDField
      FieldName = 'DIAMOUNT'
      Origin = '"DEINVOICE"."DIAMOUNT"'
      Precision = 18
      Size = 2
    end
    object qInvDINDS: TIBBCDField
      FieldName = 'DINDS'
      Origin = '"DEINVOICE"."DINDS"'
      Precision = 18
      Size = 2
    end
    object qInvOFINN: TIBStringField
      FieldName = 'OFINN'
      Origin = '"OFCOMPANIES"."OCINN"'
      Size = 12
    end
    object qInvOFBANK: TIBStringField
      FieldName = 'OFBANK'
      Origin = '"OFFBILLS"."OBBANK"'
      Size = 255
    end
    object qInvOFSETACCOUNT: TIBStringField
      FieldName = 'OFSETACCOUNT'
      Origin = '"OFFBILLS"."OBSETACCOUNT"'
    end
    object qInvOFCORACCOUNT: TIBStringField
      FieldName = 'OFCORACCOUNT'
      Origin = '"OFFBILLS"."OBCORACCOUNT"'
    end
    object qInvOFBIK: TIBStringField
      FieldName = 'OFBIK'
      Origin = '"OFFBILLS"."OBBIK"'
      Size = 10
    end
    object qInvOFNAME: TIBStringField
      FieldName = 'OFNAME'
      Origin = '"OFCOMPANIES"."OCLEGALNAME"'
      Size = 255
    end
    object qInvOFKPP: TIBStringField
      FieldName = 'OFKPP'
      Origin = '"OFCOMPANIES"."OCKPP"'
      Size = 12
    end
    object qInvOCLEGALADRESS: TIBStringField
      FieldName = 'OCLEGALADRESS'
      Origin = '"OFCOMPANIES"."OCLEGALADRESS"'
      Size = 255
    end
    object qInvOCEMAIL: TIBStringField
      FieldName = 'OCEMAIL'
      Origin = '"OFCOMPANIES"."OCEMAIL"'
      Size = 40
    end
    object qInvOCPHONE: TIBStringField
      FieldName = 'OCPHONE'
      Origin = '"OFCOMPANIES"."OCPHONE"'
      Size = 40
    end
    object qInvOCFAX: TIBStringField
      FieldName = 'OCFAX'
      Origin = '"OFCOMPANIES"."OCFAX"'
      Size = 40
    end
    object qInvOCADRESS: TIBStringField
      FieldName = 'OCADRESS'
      Origin = '"OFCOMPANIES"."OCADRESS"'
      Size = 255
    end
    object qInvOCNDS: TIntegerField
      FieldName = 'OCNDS'
      Origin = '"OFCOMPANIES"."OCNDS"'
    end
    object qInvDEBALANCE: TIBBCDField
      FieldName = 'DEBALANCE'
      Origin = '"DEINVOICE"."DIBALANCE"'
      Precision = 18
      Size = 2
    end
    object qInvOBID: TIntegerField
      FieldName = 'OBID'
      Origin = '"DEINVOICE"."OBID"'
    end
    object qInvDIID: TIntegerField
      FieldName = 'DIID'
      Origin = '"DEINVOICE"."DIID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object qInvCL_SEND: TIBStringField
      FieldName = 'CL_SEND'
      Origin = '"CLIENTS"."CLNAME"'
      Size = 255
    end
    object qInvCL_RES: TIBStringField
      FieldName = 'CL_RES'
      Origin = '"CLIENTS"."CLNAME"'
      Size = 255
    end
    object qInvEKS_NAME: TIBStringField
      FieldName = 'EKS_NAME'
      ProviderFlags = []
      Size = 255
    end
    object qInvTOWNSEND: TIBStringField
      FieldName = 'TOWNSEND'
      Origin = '"OFFICES"."OFTOWN"'
      Size = 40
    end
    object qInvTOWDEST: TIBStringField
      FieldName = 'TOWDEST'
      Origin = '"OFFICES"."OFTOWN"'
      Size = 40
    end
  end
  object qInvDet: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'Select S.SVNAME Usluga,'
      '       (DII.DVAMOUNT + DII.DVMARKUP - DII.DVHAND) Cost,'
      '       DII.DVDISCOUNT, DII.DVNDS, DII.DVTOTAL'
      '  From DEINVOICE DI'
      'INNER JOIN DESERVICES DS ON DS.DEID = DI.DEID'
      
        'INNER JOIN DEINVITEMS DII ON DII.DIID = DI.DIID AND DII.SVID = D' +
        'S.SVID'
      'INNER JOIN SERVICES S ON S.SVID = DS.SVID'
      ' Where DI.DEID = :DEID'
      '       And DS.DSPAYER = :Payer'
      '       and (DII.DVAMOUNT + DII.DVMARKUP - DII.DVHAND) > 0.0')
    Left = 40
    Top = 297
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'Payer'
        ParamType = ptInput
      end>
  end
  object qAct: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT D.DEID, COALESCE(C.CLLEGALNAME, C.CLNAME) CLNAME,'
      '       D.DEDEALNO,'
      '       D.DEENTERED, D.DEDATEOUTDEST, D.DEWAYBILL, T.TPMARKING,'
      '       T.TPSMALLPIECECNT, T.TPTRANCPIECECNT, CL.STATUSTEXT,'
      '       T.TPGOODSDESCR, D.DEISINTARE, O.BLNAMEDIR,'
      '       CAST(D.DEDATEINSEND AS DATE) AS DEDATEINSEND,'
      '       (SELECT eks_name FROM EKSPEDITOR(:deid)) AS eks_name,'
      
        '       (CASE WHEN (SELECT TE.OFMAINID FROM TERMINALS TE WHERE TE' +
        '.OFID = O.OFID) <> 1 THEN'
      
        '            (CASE WHEN O.BLISNDS = 0 THEN (SELECT O1.OFNAME FROM' +
        ' OFFICES O1 WHERE O1.OFID = 1) ELSE O.BLACTS END)'
      '       ELSE'
      '            O.BLACTS'
      '       END) AS OFNAME, O.OFID,  O.BLISNDS'
      ''
      '  FROM CLIENTSTATUS CL'
      '   INNER JOIN CLIENTS C ON (CL.CLSTATUS = C.CLSTATUS)'
      '   INNER JOIN DEALS D ON (C.CLID = D.DECLIDRECIPIENT)'
      '   INNER JOIN TRANSPORTATION T ON (D.DEID = T.DEID)'
      
        '   INNER JOIN BILLS O ON (COALESCE(D.BLIDDEST, D.DEOFIDDEST) = O' +
        '.BLID)'
      ' WHERE D.DEID = :DEID'
      '')
    Left = 72
    Top = 297
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end>
    object qActDEID: TIntegerField
      FieldName = 'DEID'
      Origin = '"DEALS"."DEID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object qActCLNAME: TIBStringField
      FieldName = 'CLNAME'
      ProviderFlags = []
      Size = 255
    end
    object qActDEDEALNO: TIBStringField
      FieldName = 'DEDEALNO'
      Origin = '"DEALS"."DEDEALNO"'
    end
    object qActDEENTERED: TDateTimeField
      FieldName = 'DEENTERED'
      Origin = '"DEALS"."DEENTERED"'
    end
    object qActDEDATEOUTDEST: TDateTimeField
      FieldName = 'DEDATEOUTDEST'
      Origin = '"DEALS"."DEDATEOUTDEST"'
    end
    object qActDEWAYBILL: TIBStringField
      FieldName = 'DEWAYBILL'
      Origin = '"DEALS"."DEWAYBILL"'
    end
    object qActTPMARKING: TIBStringField
      FieldName = 'TPMARKING'
      Origin = '"TRANSPORTATION"."TPMARKING"'
      Size = 30
    end
    object qActTPSMALLPIECECNT: TIntegerField
      FieldName = 'TPSMALLPIECECNT'
      Origin = '"TRANSPORTATION"."TPSMALLPIECECNT"'
    end
    object qActTPTRANCPIECECNT: TIntegerField
      FieldName = 'TPTRANCPIECECNT'
      Origin = '"TRANSPORTATION"."TPTRANCPIECECNT"'
    end
    object qActSTATUSTEXT: TIBStringField
      FieldName = 'STATUSTEXT'
      Origin = '"CLIENTSTATUS"."STATUSTEXT"'
      Size = 16
    end
    object qActTPGOODSDESCR: TIBStringField
      FieldName = 'TPGOODSDESCR'
      Origin = '"TRANSPORTATION"."TPGOODSDESCR"'
      Size = 255
    end
    object qActDEISINTARE: TIntegerField
      FieldName = 'DEISINTARE'
      Origin = '"DEALS"."DEISINTARE"'
    end
    object qActBLNAMEDIR: TIBStringField
      FieldName = 'BLNAMEDIR'
      Origin = '"BILLS"."BLNAMEDIR"'
      Size = 255
    end
    object qActEKS_NAME: TIBStringField
      FieldName = 'EKS_NAME'
      ProviderFlags = []
      Size = 255
    end
    object qActOFNAME: TIBStringField
      FieldName = 'OFNAME'
      ProviderFlags = []
      Size = 255
    end
    object qActOFID: TIntegerField
      FieldName = 'OFID'
      Origin = '"BILLS"."OFID"'
      Required = True
    end
    object qActBLISNDS: TIntegerField
      FieldName = 'BLISNDS'
      Origin = '"BILLS"."BLISNDS"'
    end
    object qActDEDATEINSEND: TDateField
      FieldName = 'DEDATEINSEND'
      ProviderFlags = []
    end
  end
  object qActDet: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      
        'Select cast('#39#1058#1088#1072#1085#1089#1087#1086#1088#1090#1085#1086'-'#1101#1082#1089#1087#1077#1076#1080#1094#1080#1086#1085#1085#1099#1077' '#1091#1089#1083#1091#1075#1080' ('#39'||OFSEND.OFTOWN' +
        '||'#39'-'#39'||'
      
        '       OFDEST.OFTOWN||'#39' '#1087#1086' '#1087#1086#1088#1091#1095#1077#1085#1080#1102' '#1101#1082#1089#1087#1077#1076#1080#1090#1086#1088#1091' '#39'|| (SELECT eks' +
        '_name FROM EKSPEDITOR(:DEID)) ||'#39' '#8470#39'||de.DEDEALNO||'
      '       '#39' '#1086#1090' '#39'||'
      
        '       EXTRACT( DAY FROM de.DEDATEINSEND)||'#39'.'#39'||EXTRACT(MONTH FR' +
        'OM de.DEDATEINSEND)||'#39'.'#39'||'
      '       EXTRACT( YEAR FROM de.DEDATEINSEND) ||'
      '       '#39')'#39' As Varchar(355)) Usluga,'
      '       cast((t.Tpcostnotstdpiece + t.Tpcoststdpiece +'
      '       ((t.Tpcostnotstdpiece + t.Tpcoststdpiece)/'
      
        '        (t.Tpcostnotstdpiece + t.Tpcostpacking + t.Tpcoststdpiec' +
        'e)*'
      '        t.Tpnsptransportation)) as Numeric(15,2)) Cost,'
      '       cl.Typetext,'
      '       cast(((t.Tpcostnotstdpiece + t.Tpcoststdpiece)/'
      
        '        (t.Tpcostnotstdpiece + t.Tpcostpacking + t.Tpcoststdpiec' +
        'e)*'
      '        t.Tpndstransportation) as Numeric(15,2)) NDS,'
      '       cast(((t.Tpcostnotstdpiece + t.Tpcoststdpiece)/'
      
        '        (t.Tpcostnotstdpiece + t.Tpcostpacking + t.Tpcoststdpiec' +
        'e)*'
      '        t.Tpnsptransportation) as Numeric(15,2)) NSP'
      '  From Transportation t'
      ' INNER JOIN CLIENTTYPE CL ON (CL.CLTYPE = T.Tppaytransportation)'
      ' INNER JOIN DEALS de ON (de.DEID = T.DEID)'
      ' INNER JOIN OFFICES OFSEND ON OFSEND.OFID = DE.DEOFIDSEND'
      ' INNER JOIN OFFICES OFDEST ON OFDEST.OFID = DE.DEOFIDDEST'
      ' Where t.Deid = :DEID'
      '   And t.Tppaytransportation = :Payer'
      
        '   and CAST((t.Tpcostnotstdpiece + t.Tpcoststdpiece) AS NUMERIC(' +
        '15,2)) > 0.0'
      'Union'
      'Select cast('#39#1059#1087#1072#1082#1086#1074#1082#1072' '#1075#1088#1091#1079#1072#39' As Varchar(80)) Usluga,'
      '       cast(tp.Tpcostpacking +'
      '       (tp.Tpcostpacking/'
      
        '        (tp.Tpcostnotstdpiece + tp.Tpcostpacking + tp.Tpcoststdp' +
        'iece)*'
      '        tp.Tpnsptransportation) as Numeric(15,2)) Cost,'
      '       cl.Typetext,'
      '       cast((tp.Tpcostpacking/'
      
        '        (tp.Tpcostnotstdpiece + tp.Tpcostpacking + tp.Tpcoststdp' +
        'iece)*'
      '        tp.Tpndstransportation) as Numeric(15,2)) NDS,'
      '       cast((tp.Tpcostpacking/'
      
        '        (tp.Tpcostnotstdpiece + tp.Tpcostpacking + tp.Tpcoststdp' +
        'iece)*'
      '        tp.Tpnsptransportation) as Numeric(15,2)) NSP'
      '  From Transportation tp'
      
        ' INNER JOIN CLIENTTYPE CL ON (CL.CLTYPE = Tp.Tppaytransportation' +
        ')'
      ' Where tp.Deid = :DEID'
      '   And tp.Tppaytransportation = :Payer'
      '   and CAST(tp.Tpcostpacking AS NUMERIC(15,2)) > 0.0'
      'Union'
      
        'Select cast('#39#1047#1072#1073#1086#1088' '#1075#1088#1091#1079#1072' ('#39'||a.ATDESCRIPTION||'#39')'#39' As Varchar(80)' +
        ') Usluga,'
      '       cast(c.Cacostcapture as Numeric(15,2)) Cost, cl.Typetext,'
      '       cast(c.Candscapture as Numeric(15,2)) NDS,'
      '       cast(c.Canspcapture as Numeric(15,2)) NSP'
      '  FROM Captures c'
      ' INNER JOIN AUTOTYPES a ON (a.ATID = c.ATID)'
      ' INNER JOIN CLIENTTYPE CL ON (CL.CLTYPE = c.Capaycapture)'
      ' Where c.Deid = :DEID'
      '   And c.CAPAYCAPTURE = :Payer'
      '   and CAST(c.CACOSTCAPTURE AS NUMERIC(15,2)) > 0.0'
      'Union'
      
        'SELECT cast('#39#1044#1086#1089#1090#1072#1074#1082#1072' '#1075#1088#1091#1079#1072' ('#39'||a.ATDESCRIPTION||'#39')'#39' As Varchar(' +
        '80)) Usluga,'
      
        '       cast(d.DVCOSTDELIVERY as Numeric(15,2)) COST, cl.Typetext' +
        ','
      '       cast(d.Dvndsdelivery as Numeric(15,2)) NDS,'
      '       cast(d.Dvnspdelivery as Numeric(15,2)) NSP'
      '  FROM DELIVERY d'
      ' INNER JOIN AUTOTYPES a ON (a.ATID = d.ATID)'
      ' INNER JOIN CLIENTTYPE CL ON (CL.CLTYPE = d.DVPAYDELIVERY)'
      ' WHERE d.DEID = :DEID'
      '   And d.DVPAYDELIVERY = :Payer'
      '   and CAST(d.DVCOSTDELIVERY AS NUMERIC(15,2)) > 0.0'
      'UNION'
      'Select cast('#39#1055#1083#1086#1084#1073#1080#1088#1086#1074#1082#1072' '#1075#1088#1091#1079#1072#39' As Varchar(80)) Usluga,'
      '       cast(AD.ASSEALSCOST as Numeric(15,2)) COST, cl.Typetext,'
      '       cast(AD.ASSEALSNDS as Numeric(15,2)) NDS,'
      '       cast(0.0 as Numeric(15,2)) NSP'
      '  From ADDSERVICE AD'
      ' INNER JOIN CLIENTTYPE CL ON (CL.CLTYPE = AD.ASPAYER)'
      ' Where AD.Deid = :DEID'
      '   And AD.ASPAYER = :Payer'
      '   and CAST(AD.ASSEALSCOST AS NUMERIC(15,2)) > 0.0'
      'UNION'
      'Select cast('#39#1054#1087#1086#1074#1077#1097#1077#1085#1080#1077' '#1087#1086' SMS'#39' As Varchar(80)) Usluga,'
      '       cast(S.SS_COST as Numeric(15,2)) COST, cl.Typetext,'
      '       cast(S.SS_NDS as Numeric(15,2)) NDS,'
      '       cast(0.0 as Numeric(15,2)) NSP'
      '  From Transportation tp'
      
        ' INNER JOIN CLIENTTYPE CL ON (CL.CLTYPE = Tp.Tppaytransportation' +
        ')'
      ' INNER JOIN SMS S ON (S.DEID = Tp.DEID)'
      ' Where tp.Deid = :DEID'
      '   And tp.Tppaytransportation = :Payer'
      '   and CAST(S.SS_COST AS NUMERIC(15,2)) > 0.0'
      'UNION'
      'Select cast('#39#1042#1085#1091#1090#1088#1080#1090#1072#1088#1085#1072#1103' '#1087#1088#1080#1105#1084#1082#1072#39' As Varchar(80)) Usluga,'
      '       cast(IT.IRCOST as Numeric(15,2)) COST, cl.Typetext,'
      '       cast(IT.IRNDS as Numeric(15,2)) NDS,'
      '       cast(0.0 as Numeric(15,2)) NSP'
      '  From INTARE IT'
      ' INNER JOIN CLIENTTYPE CL ON (CL.CLTYPE = IT.IRPAYER)'
      ' Where IT.Deid = :DEID'
      '   And IT.IRPAYER = :Payer'
      '   and CAST(IT.IRCOST AS NUMERIC(15,2)) > 0.0'
      'UNION'
      'Select cast('#39#1042#1086#1079#1074#1088#1072#1090' '#1058#1053#39' As Varchar(80)) Usluga,'
      '       cast(RD.RTCOST as Numeric(15,2)) COST, cl.Typetext,'
      '       cast(RD.RTNDS as Numeric(15,2)) NDS,'
      '       cast(0.0 as Numeric(15,2)) NSP'
      '  From RETURNDOC RD'
      ' INNER JOIN CLIENTTYPE CL ON (CL.CLTYPE = RD.RTPAYER)'
      ' Where RD.Deid = :DEID'
      '   And RD.RTPAYER = :Payer'
      '   and CAST(RD.RTCOST AS NUMERIC(15,2)) > 0.0'
      ''
      '')
    Left = 104
    Top = 297
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'Payer'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'Payer'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'Payer'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'Payer'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'Payer'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'Payer'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'Payer'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'Payer'
        ParamType = ptInput
      end>
  end
  object qFact: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT D.DEID, D.DEENTERED, DI.DIID,'
      '       (CASE CL.CLTYPE'
      
        '       WHEN 1001 THEN CJ.CLLEGALNAME ELSE CL.CLNAME END) AS CLLE' +
        'GALNAME,'
      '       CJ.CLLEGALADRES, CJ.CLINN, CJ.CLKPP,'
      '       O.OCKPP, O.OCINN, O.OCLEGALNAME,'
      '       O.OCLEGALADRESS, O.OCDIRECTOR, O.OCGLAVBUH,'
      
        '       '#39#1054#1073#1097#1077#1089#1090#1074#1086' '#1089' '#1086#1075#1088#1072#1085#1080#1095#1077#1085#1085#1086#1081' '#1086#1090#1074#1077#1090#1089#1090#1074#1077#1085#1085#1086#1089#1090#1100#1102' '#39'||SUBSTRING(O.' +
        'OCLEGALNAME FROM 4)||'#39' ('#39'||O.OCLEGALNAME||'#39')'#39' AS full_name'
      'FROM DEALS D'
      'INNER JOIN DEINVOICE DI ON DI.DEID = D.DEID AND DI.CLID ='
      '      CASE :Payer'
      '        WHEN 0 THEN D.DECLID_S'
      '        WHEN 1 THEN D.DECLID_R'
      '        WHEN 2 THEN D.DECLID_3'
      '      END'
      'INNER JOIN CLIENTS CL ON Cl.CLID = DI.CLID'
      'INNER JOIN OFCOMPANIES O ON O.OFID = DI.OBID'
      'LEFT OUTER JOIN CLIENTS_J CJ ON CJ.CLID = DI.CLID'
      'WHERE D.DEID = :DEID'
      '      AND EXISTS('
      '      SELECT DS.DEID'
      '      FROM DESERVICES DS'
      '      WHERE DS.DEID = D.DEID'
      '            AND DS.DSPAYER ='
      '               CASE :Payer'
      '        WHEN 0 THEN 1098'
      '        WHEN 1 THEN 1099'
      '        WHEN 2 THEN 1100'
      '      END'
      '      )')
    Left = 392
    Top = 217
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'Payer'
        ParamType = ptUnknown
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
        Value = '17892'
      end
      item
        DataType = ftUnknown
        Name = 'Payer'
        ParamType = ptUnknown
      end>
  end
  object qFactDetIns: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      
        'Select cast('#39#1057#1090#1088#1072#1093#1086#1074#1082#1072' '#1075#1088#1091#1079#1072' '#1085#1072' '#1089#1091#1084#1084#1091' '#39'||I.DIPRECOST||'#39' '#1088#1091#1073'.'#39' As' +
        ' Varchar(80)) Usluga,'
      '       DII.DVTOTAL AS Cost, DII.DVTOTAL AS Cost2,'
      '       cast('#39'---'#39' as VARCHAR(3)) Stavka,'
      '       cast(0.0 as Numeric(15,2)) AS DVNDS, S.SVID'
      'FROM DEINVOICE DI'
      'INNER JOIN DESERVICES DS ON DS.DEID = DI.DEID'
      
        'INNER JOIN DEINVITEMS DII ON DII.DIID = DI.DIID AND DII.SVID = D' +
        'S.SVID'
      'INNER JOIN SERVICES S ON S.SVID = DS.SVID'
      'INNER JOIN DEINSURANCE I ON I.DEID = DI.DEID'
      ' WHERE DI.DEID = :DEID'
      '       AND DS.DSPAYER ='
      '       CASE :Payer'
      '        WHEN 0 THEN 1098'
      '        WHEN 1 THEN 1099'
      '        WHEN 2 THEN 1100'
      '       END'
      '       AND S.SVID = 5'
      '       AND DII.DVTOTAL > 0.0'
      '')
    Left = 424
    Top = 281
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
        Value = '17892'
      end
      item
        DataType = ftInteger
        Name = 'Payer'
        ParamType = ptInput
        Value = '0'
      end>
  end
  object qTicket: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT D.DEID, COALESCE(C.CLLEGALNAME, C.CLNAME) CLNAME,'
      '       O.OFNAME OFNAME, D.DEDEALNO,'
      '       D.DEENTERED, D.DEDATEOUTDEST, D.DEWAYBILL, T.TPMARKING,'
      '       T.TPSMALLPIECECNT, T.TPTRANCPIECECNT, CL.STATUSTEXT,'
      '       T.TPGOODSDESCR, D.DEISINTARE'
      '  FROM CLIENTSTATUS CL'
      '   INNER JOIN CLIENTS C ON (CL.CLSTATUS = C.CLSTATUS)'
      '   INNER JOIN DEALS D ON (C.CLID = D.DECLIDRECIPIENT)'
      '   INNER JOIN TRANSPORTATION T ON (D.DEID = T.DEID)'
      '   INNER JOIN OFFICES O ON O.OFID = D.DEOFIDDEST'
      ' WHERE D.DEID = :DEID')
    Left = 224
    Top = 297
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end>
  end
  object qKvit: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT D.DEDEALNO,'
      '       CAST(D.DEDATEINSEND AS DATE) AS DEDATEINSEND1,'
      '       CAST(D.DEDATERECIPIENT AS DATE) AS DEDATERECIPIENT,'
      '       OS.OFTOWN AS punkt_otpr, OD.OFTOWN AS punkt_nazn,'
      
        '       COALESCE(CLSEND.CLLEGALNAME, CLSEND.CLNAME) AS otpravitel' +
        ', CLSEND.CLPHONEWAREHOUSE1 AS phone_otpr,'
      '       CLSEND.CLADDRESSWAREHOUSE AS adress_otpr,'
      
        '       (CASE WHEN T.TPPAYTRANSPORTATION = '#39'0'#39' THEN COALESCE(CLSE' +
        'ND.CLLEGALNAME, CLSEND.CLNAME) ELSE COALESCE(CLDEST.CLLEGALNAME,' +
        ' CLDEST.CLNAME) END) AS klient,'
      
        '       COALESCE(CLDEST.CLLEGALNAME, CLDEST.CLNAME) AS poluchatel' +
        ', CLDEST.CLPHONEWAREHOUSE1 AS phone_pol, CLDEST.CLADDRESSWAREHOU' +
        'SE AS adress_pol,'
      
        '       (SELECT eks_name FROM EKSPEDITOR(:DEID)) AS eks_name, (SE' +
        'LECT eks_phone FROM EKSPEDITOR(:DEID)) as eks_phone,'
      '       (SELECT eks_adress FROM EKSPEDITOR(:DEID)) AS eks_adress,'
      '       T.TPGOODSDESCR AS xarakter_gr,'
      
        '       (CASE WHEN T.TPPAYTRANSPORTATION = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELS' +
        'E '#39#1087#1086#1083#1091#1095'.'#39' END) AS usl_transp,'
      '       CASE WHEN CA.CAPAYCAPTURE IS NOT NULL THEN'
      
        '       (CASE WHEN CA.CAPAYCAPTURE = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083 +
        #1091#1095'.'#39' END)'
      '       END  AS usl_zabor,'
      '       CASE WHEN DE.DVPAYDELIVERY IS NOT NULL THEN'
      
        '       (CASE WHEN DE.DVPAYDELIVERY = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086 +
        #1083#1091#1095'.'#39' END)'
      '       END  AS usl_dost,'
      '       (CASE WHEN PA.PTNAME <> '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080#39' THEN'
      
        '             (CASE WHEN T.TPPAYTRANSPORTATION = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074 +
        '.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' END) END)  AS usl_ju,'
      
        '       (CASE WHEN (T.TPVSTDSOFTPACK + T.TPVNOTSTDSOFTPACK) > 0.0' +
        '0 THEN'
      
        '             (CASE WHEN T.TPPAYTRANSPORTATION = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074 +
        '.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' END) END)  AS usl_mu,'
      '       CASE WHEN A.ASPAYER IS NOT NULL THEN'
      
        '       (CASE WHEN A.ASPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_plomb,'
      '       CASE WHEN I.IRPAYER IS NOT NULL THEN'
      
        '       (CASE WHEN I.IRPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_vnutrit,'
      
        '       CASE WHEN ((R.RTPAYER IS NOT NULL) AND (R.RTTYPE = 2)) TH' +
        'EN'
      
        '       (CASE WHEN R.RTPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_vozvr_torg12,'
      
        '       CASE WHEN ((R.RTPAYER IS NOT NULL) AND (R.RTTYPE = 1)) TH' +
        'EN'
      
        '       (CASE WHEN R.RTPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_vozvr_email,'
      
        '       CASE WHEN (S.SS_S_PHONE IS NOT NULL) THEN (CASE WHEN T.TP' +
        'PAYTRANSPORTATION = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' END) END  A' +
        'S usl_sms_otpr,'
      
        '       CASE WHEN (S.SS_D_PHONE IS NOT NULL) THEN (CASE WHEN T.TP' +
        'PAYTRANSPORTATION = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' END) END  A' +
        'S usl_sms_poluch,'
      '       CASE WHEN IR.ICPAYINSURANCE IS NOT NULL THEN'
      
        '       (CASE WHEN IR.ICPAYINSURANCE = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087 +
        #1086#1083#1091#1095'.'#39' END)'
      '       END  AS usl_strax,'
      
        '       T.TPDOPINF,  T.TPMARKING, T.TPSMALLPIECECNT, (T.TPSTDWEIG' +
        'HT + T.TPNOTSTDWEIGHT) AS ves,'
      '       (T.TPSTDVOLUME + T.TPNOTSTDVOLUME) AS volume,'
      '       A.ASSEALSCNT,'
      
        '       (CASE WHEN A.ASSEALSCNT IS NOT NULL THEN A.ASITEMS ELSE '#39 +
        #1053#1077' '#1091#1089#1090#1072#1085#1086#1074#1083#1077#1085#1099#39' END) AS nom_plomb,'
      
        '       OS.OFNAME AS gruz_prinyal, IIF(:is21vek = 1,(SELECT eks_n' +
        'ame FROM EKSPEDITOR(:DEID)),OD.OFNAME) AS gruz_vydal,'
      '       T.TPTRANCPIECECNT, DE.DVPAYDELIVERY,'
      
        '       (CASE WHEN ((T.TPCONDPACK IS NULL) OR (T.TPCONDPACK = 0))' +
        ' THEN '#39#1042' '#1085#1086#1088#1084#1077#39
      '             WHEN T.TPCONDPACK = 1 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080#39
      '             WHEN T.TPCONDPACK = 2 THEN '#39#1053#1077#1085#1072#1076#1083#1077#1078#1072#1097#1072#1103#39
      '             WHEN T.TPCONDPACK = 3 THEN '#39#1055#1086#1074#1088#1077#1078#1076#1077#1085#1072#39
      
        '             WHEN T.TPCONDPACK = 4 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080' '#1080' '#1085#1077#1085#1072#1076#1083#1077#1078 +
        #1072#1097#1072#1103#39
      
        '             WHEN T.TPCONDPACK = 5 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080' '#1080' '#1087#1086#1074#1088#1077#1078#1076#1077 +
        #1085#1072#39
      
        '             WHEN T.TPCONDPACK = 6 THEN '#39#1055#1086#1074#1088#1077#1078#1076#1077#1085#1072' '#1080' '#1085#1077#1085#1072#1076#1083#1077#1078#1072#1097 +
        #1072#1103#39
      
        '             WHEN T.TPCONDPACK = 7 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082'., '#1087#1086#1074#1088#1077#1078#1076#1077#1085#1072' '#1080 +
        ' '#1085#1077#1085#1072#1076#1083#1077#1078#1072#1097#1072#1103#39
      '        END) AS upak_klienta'
      ''
      'FROM DEALS D'
      'INNER JOIN TRANSPORTATION T ON T.DEID = D.DEID'
      'INNER JOIN CLIENTS CLSEND ON CLSEND.CLID = D.DECLIDSENDER'
      'INNER JOIN CLIENTS CLDEST ON CLDEST.CLID = D.DECLIDRECIPIENT'
      'INNER JOIN OFFICES OS ON OS.OFID = D.DEOFIDSEND'
      'INNER JOIN OFFICES OD ON OD.OFID = D.DEOFIDDEST'
      'LEFT OUTER JOIN CAPTURES CA ON CA.DEID = D.DEID'
      'LEFT OUTER JOIN DELIVERY DE ON DE.DEID = D.DEID'
      'LEFT OUTER JOIN PACKINGTYPES PA ON PA.PTID = T.PTID'
      'LEFT OUTER JOIN ADDSERVICE A ON A.DEID = D.DEID'
      'LEFT OUTER JOIN INTARE I ON I.DEID = D.DEID'
      'LEFT OUTER JOIN RETURNDOC R ON R.DEID = D.DEID'
      'LEFT OUTER JOIN SMS S ON S.DEID = D.DEID'
      'LEFT OUTER JOIN INSURANCE IR ON IR.DEID = D.DEID'
      'WHERE D.DEID = :DEID'
      '')
    Left = 264
    Top = 297
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftUnknown
        Name = 'is21vek'
        ParamType = ptUnknown
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end>
    object qKvitDEDEALNO: TIBStringField
      FieldName = 'DEDEALNO'
      Origin = '"DEALS"."DEDEALNO"'
    end
    object qKvitPUNKT_OTPR: TIBStringField
      FieldName = 'PUNKT_OTPR'
      Origin = '"OFFICES"."OFTOWN"'
    end
    object qKvitPUNKT_NAZN: TIBStringField
      FieldName = 'PUNKT_NAZN'
      Origin = '"OFFICES"."OFTOWN"'
    end
    object qKvitOTPRAVITEL: TIBStringField
      FieldName = 'OTPRAVITEL'
      Origin = '"CLIENTS"."CLNAME"'
      Size = 255
    end
    object qKvitPHONE_OTPR: TIBStringField
      FieldName = 'PHONE_OTPR'
      Origin = '"CLIENTS"."CLPHONEWAREHOUSE1"'
    end
    object qKvitADRESS_OTPR: TIBStringField
      FieldName = 'ADRESS_OTPR'
      Origin = '"CLIENTS"."CLADDRESSWAREHOUSE"'
      Size = 255
    end
    object qKvitKLIENT: TIBStringField
      FieldName = 'KLIENT'
      Origin = '"CLIENTS"."CLNAME"'
      Size = 255
    end
    object qKvitPOLUCHATEL: TIBStringField
      FieldName = 'POLUCHATEL'
      Origin = '"CLIENTS"."CLNAME"'
      Size = 255
    end
    object qKvitPHONE_POL: TIBStringField
      FieldName = 'PHONE_POL'
      Origin = '"CLIENTS"."CLPHONEWAREHOUSE1"'
    end
    object qKvitADRESS_POL: TIBStringField
      FieldName = 'ADRESS_POL'
      Origin = '"CLIENTS"."CLADDRESSWAREHOUSE"'
      Size = 255
    end
    object qKvitEKS_NAME: TIBStringField
      FieldName = 'EKS_NAME'
      ProviderFlags = []
      Size = 255
    end
    object qKvitEKS_ADRESS: TIBStringField
      FieldName = 'EKS_ADRESS'
      ProviderFlags = []
      Size = 255
    end
    object qKvitXARAKTER_GR: TIBStringField
      FieldName = 'XARAKTER_GR'
      Origin = '"TRANSPORTATION"."TPGOODSDESCR"'
      Size = 255
    end
    object qKvitUSL_TRANSP: TIBStringField
      FieldName = 'USL_TRANSP'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qKvitUSL_ZABOR: TIBStringField
      FieldName = 'USL_ZABOR'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qKvitUSL_DOST: TIBStringField
      FieldName = 'USL_DOST'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qKvitUSL_JU: TIBStringField
      FieldName = 'USL_JU'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qKvitUSL_MU: TIBStringField
      FieldName = 'USL_MU'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qKvitUSL_PLOMB: TIBStringField
      FieldName = 'USL_PLOMB'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qKvitUSL_VNUTRIT: TIBStringField
      FieldName = 'USL_VNUTRIT'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qKvitUSL_VOZVR_TORG12: TIBStringField
      FieldName = 'USL_VOZVR_TORG12'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qKvitUSL_VOZVR_EMAIL: TIBStringField
      FieldName = 'USL_VOZVR_EMAIL'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qKvitUSL_SMS_OTPR: TIBStringField
      FieldName = 'USL_SMS_OTPR'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qKvitUSL_SMS_POLUCH: TIBStringField
      FieldName = 'USL_SMS_POLUCH'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qKvitUSL_STRAX: TIBStringField
      FieldName = 'USL_STRAX'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object qKvitTPDOPINF: TIBStringField
      FieldName = 'TPDOPINF'
      Origin = '"TRANSPORTATION"."TPDOPINF"'
      Size = 100
    end
    object qKvitTPMARKING: TIBStringField
      FieldName = 'TPMARKING'
      Origin = '"TRANSPORTATION"."TPMARKING"'
      Size = 30
    end
    object qKvitTPSMALLPIECECNT: TIntegerField
      FieldName = 'TPSMALLPIECECNT'
      Origin = '"TRANSPORTATION"."TPSMALLPIECECNT"'
    end
    object qKvitVES: TFloatField
      FieldName = 'VES'
      ProviderFlags = []
    end
    object qKvitVOLUME: TFloatField
      FieldName = 'VOLUME'
      ProviderFlags = []
    end
    object qKvitASSEALSCNT: TIntegerField
      FieldName = 'ASSEALSCNT'
      Origin = '"ADDSERVICE"."ASSEALSCNT"'
    end
    object qKvitNOM_PLOMB: TIBStringField
      FieldName = 'NOM_PLOMB'
      ProviderFlags = []
      Size = 100
    end
    object qKvitGRUZ_PRINYAL: TIBStringField
      FieldName = 'GRUZ_PRINYAL'
      Origin = '"OFFICES"."OFNAME"'
      Size = 80
    end
    object qKvitGRUZ_VYDAL: TIBStringField
      FieldName = 'GRUZ_VYDAL'
      Origin = '"OFFICES"."OFNAME"'
      Size = 80
    end
    object qKvitTPTRANCPIECECNT: TIntegerField
      FieldName = 'TPTRANCPIECECNT'
      Origin = '"TRANSPORTATION"."TPTRANCPIECECNT"'
    end
    object qKvitDVPAYDELIVERY: TIBStringField
      FieldName = 'DVPAYDELIVERY'
      Origin = '"DELIVERY"."DVPAYDELIVERY"'
      Size = 1
    end
    object qKvitEKS_PHONE: TIBStringField
      FieldName = 'EKS_PHONE'
      ProviderFlags = []
      Size = 255
    end
    object qKvitDEDATEINSEND1: TDateField
      FieldName = 'DEDATEINSEND1'
      ProviderFlags = []
    end
    object qKvitDEDATERECIPIENT: TDateField
      FieldName = 'DEDATERECIPIENT'
      ProviderFlags = []
    end
    object qKvitUPAK_KLIENTA: TIBStringField
      FieldName = 'UPAK_KLIENTA'
      ProviderFlags = []
      FixedChar = True
      Size = 36
    end
  end
  object rvdsKvit: TRvDataSetConnection
    LocalFilter = False
    RuntimeVisibility = rtEndUser
    DataSet = qKvit
    Left = 280
    Top = 296
  end
  object qIsNDS_send: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT T.OFMAINID'
      'FROM DEALS D'
      'JOIN BILLS B ON B.BLID = D.BLIDSEND'
      'JOIN TERMINALS T ON T.OFID = B.OFID'
      'WHERE D.DEID = :DEID AND B.BLISNDS = 1 AND T.OFMAINID = 1')
    Left = 320
    Top = 297
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end>
  end
  object qIsNDS_dest: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT T.OFMAINID'
      'FROM DEALS D'
      'JOIN BILLS B ON B.BLID = D.BLIDDEST'
      'JOIN TERMINALS T ON T.OFID = B.OFID'
      'WHERE D.DEID = :DEID AND B.BLISNDS = 1 AND T.OFMAINID = 1')
    Left = 352
    Top = 297
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'DEID'
        ParamType = ptUnknown
      end>
  end
  object rvdsFactDet: TRvDataSetConnection
    LocalFilter = False
    RuntimeVisibility = rtEndUser
    DataSet = qFactDet
    Left = 424
    Top = 216
  end
  object rvdsFactSender: TRvDataSetConnection
    LocalFilter = False
    RuntimeVisibility = rtEndUser
    DataSet = qFact
    Left = 136
    Top = 320
  end
  object rvdsActDet: TRvDataSetConnection
    LocalFilter = False
    RuntimeVisibility = rtEndUser
    DataSet = qActDet
    Left = 104
    Top = 320
  end
  object rvdsAct: TRvDataSetConnection
    LocalFilter = False
    RuntimeVisibility = rtEndUser
    DataSet = qAct
    Left = 72
    Top = 320
  end
  object rvdsInvSenderDet: TRvDataSetConnection
    LocalFilter = False
    RuntimeVisibility = rtEndUser
    DataSet = qInvDet
    Left = 40
    Top = 320
  end
  object rvdsInvSender: TRvDataSetConnection
    LocalFilter = False
    RuntimeVisibility = rtEndUser
    DataSet = qInv
    Left = 8
    Top = 320
  end
  object qCheckAct: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT D.DEID, D.DEBALANCE, DV.DVPAYMETHOD,'
      '       D.DEBALANCESENDER, D.DEBALANCERECIPIENT,'
      '       P.PSSEND, P.PSDEST, D.DEDATEINDEST'
      '  FROM DEALS D'
      '  LEFT OUTER JOIN DELIVERY DV ON (D.DEID = DV.DEID)'
      '  LEFT OUTER JOIN PERMITS P ON (D.DEID = P.DEID)'
      ' WHERE D.DEID = :DEID')
    Left = 72
    Top = 337
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end>
    object qCheckActDEID: TIntegerField
      FieldName = 'DEID'
      Origin = 'DEALS.DEID'
      Required = True
    end
    object qCheckActDEBALANCE: TFloatField
      FieldName = 'DEBALANCE'
      Origin = 'DEALS.DEBALANCE'
    end
    object qCheckActDVPAYMETHOD: TIBStringField
      FieldName = 'DVPAYMETHOD'
      Origin = 'DELIVERY.DVPAYMETHOD'
      Size = 1
    end
    object qCheckActDEBALANCESENDER: TFloatField
      FieldName = 'DEBALANCESENDER'
      Origin = '"DEALS"."DEBALANCESENDER"'
    end
    object qCheckActDEBALANCERECIPIENT: TFloatField
      FieldName = 'DEBALANCERECIPIENT'
      Origin = '"DEALS"."DEBALANCERECIPIENT"'
    end
    object qCheckActPSSEND: TIBStringField
      FieldName = 'PSSEND'
      Origin = '"PERMITS"."PSSEND"'
      Size = 1
    end
    object qCheckActPSDEST: TIBStringField
      FieldName = 'PSDEST'
      Origin = '"PERMITS"."PSDEST"'
      Size = 1
    end
    object qCheckActDEDATEINDEST: TDateTimeField
      FieldName = 'DEDATEINDEST'
      Origin = '"DEALS"."DEDATEINDEST"'
    end
  end
  object qActSender: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT D.DEID, COALESCE(C.CLLEGALNAME, C.CLNAME) CLNAME,'
      '        D.DEDEALNO,'
      '       D.DEENTERED, D.DEDATEOUTDEST, D.DEWAYBILL, T.TPMARKING,'
      
        '       T.TPSMALLPIECECNT, T.TPTRANCPIECECNT, CL.STATUSTEXT, O.BL' +
        'NAMEDIR,'
      '       CAST(D.DEDATEINSEND AS DATE) AS DEDATEINSEND,'
      '       (SELECT eks_name FROM EKSPEDITOR(:deid)) AS eks_name,'
      
        '       (CASE WHEN (SELECT TE.OFMAINID FROM TERMINALS TE WHERE TE' +
        '.OFID = O.OFID) <> 1 THEN'
      
        '            (CASE WHEN O.BLISNDS = 0 THEN (SELECT O1.OFNAME FROM' +
        ' OFFICES O1 WHERE O1.OFID = 1) ELSE O.BLACTS END)'
      '       ELSE'
      '            O.BLACTS'
      '       END) AS OFNAME, O.OFID,  O.BLISNDS'
      '  FROM CLIENTSTATUS CL'
      ' INNER JOIN CLIENTS C ON (CL.CLSTATUS = C.CLSTATUS)'
      ' INNER JOIN DEALS D ON (C.CLID = D.DECLIDSENDER)'
      ' INNER JOIN TRANSPORTATION T ON (D.DEID = T.DEID)'
      
        ' INNER JOIN BILLS O ON (COALESCE(D.BLIDSEND, D.DEOFIDSEND) = O.B' +
        'LID)'
      ' WHERE D.DEID = :DEID')
    Left = 104
    Top = 337
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end>
    object qActSenderDEID: TIntegerField
      FieldName = 'DEID'
      Origin = '"DEALS"."DEID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object qActSenderCLNAME: TIBStringField
      FieldName = 'CLNAME'
      ProviderFlags = []
      Size = 255
    end
    object qActSenderOFNAME: TIBStringField
      FieldName = 'OFNAME'
      Origin = '"BILLS"."BLACTS"'
      Size = 255
    end
    object qActSenderDEDEALNO: TIBStringField
      FieldName = 'DEDEALNO'
      Origin = '"DEALS"."DEDEALNO"'
    end
    object qActSenderDEENTERED: TDateTimeField
      FieldName = 'DEENTERED'
      Origin = '"DEALS"."DEENTERED"'
    end
    object qActSenderDEDATEOUTDEST: TDateTimeField
      FieldName = 'DEDATEOUTDEST'
      Origin = '"DEALS"."DEDATEOUTDEST"'
    end
    object qActSenderDEWAYBILL: TIBStringField
      FieldName = 'DEWAYBILL'
      Origin = '"DEALS"."DEWAYBILL"'
    end
    object qActSenderTPMARKING: TIBStringField
      FieldName = 'TPMARKING'
      Origin = '"TRANSPORTATION"."TPMARKING"'
      Size = 30
    end
    object qActSenderTPSMALLPIECECNT: TIntegerField
      FieldName = 'TPSMALLPIECECNT'
      Origin = '"TRANSPORTATION"."TPSMALLPIECECNT"'
    end
    object qActSenderTPTRANCPIECECNT: TIntegerField
      FieldName = 'TPTRANCPIECECNT'
      Origin = '"TRANSPORTATION"."TPTRANCPIECECNT"'
    end
    object qActSenderSTATUSTEXT: TIBStringField
      FieldName = 'STATUSTEXT'
      Origin = '"CLIENTSTATUS"."STATUSTEXT"'
      Size = 16
    end
    object qActSenderBLNAMEDIR: TIBStringField
      FieldName = 'BLNAMEDIR'
      Origin = '"BILLS"."BLNAMEDIR"'
      Size = 255
    end
    object qActSenderEKS_NAME: TIBStringField
      FieldName = 'EKS_NAME'
      ProviderFlags = []
      Size = 255
    end
    object qActSenderOFID: TIntegerField
      FieldName = 'OFID'
      Origin = '"BILLS"."OFID"'
      Required = True
    end
    object qActSenderBLISNDS: TIntegerField
      FieldName = 'BLISNDS'
      Origin = '"BILLS"."BLISNDS"'
    end
    object qActSenderDEDATEINSEND: TDateField
      FieldName = 'DEDATEINSEND'
      ProviderFlags = []
    end
  end
  object qFactDet: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      
        'SELECT CAST('#39#1058#1088#1072#1085#1089#1087#1086#1088#1090#1085#1086'-'#1101#1082#1089#1087#1077#1076#1080#1094#1080#1086#1085#1085#1099#1077' '#1091#1089#1083#1091#1075#1080' ('#39'||OFSEND.OFTOWN' +
        '||'#39'-'#39'||'
      
        '       OFDEST.OFTOWN||'#39' '#1087#1086' '#1087#1086#1088#1091#1095#1077#1085#1080#1102' '#1101#1082#1089#1087#1077#1076#1080#1090#1086#1088#1091' '#39'|| (SELECT eks' +
        '_name FROM EKSPEDITOR(:DEID)) ||'#39' '#8470#39'||de.DEID||'
      '       '#39' '#1086#1090' '#39'||'
      
        '       EXTRACT( DAY FROM de.DEDATEINSEND)||'#39'.'#39'||EXTRACT(MONTH FR' +
        'OM de.DEDATEINSEND)||'#39'.'#39'||'
      '       EXTRACT( YEAR FROM de.DEDATEINSEND) ||'
      '       '#39')'#39' As Varchar(355)) AS Usluga,'
      '       (DII.DVTOTAL - DII.DVNDS) AS Cost,'
      
        '       DII.DVTOTAL AS Cost2, IIF ((DII.DVTOTAL - DII.DVNDS) > 0.' +
        '0, CAST(CAST((DII.DVNDS * 100.0) / (DII.DVTOTAL - DII.DVNDS) AS ' +
        'INTEGER)||'#39'%'#39' AS VARCHAR(3)), '#39'0%'#39') AS Stavka,'
      '       DII.DVNDS,  S.SVID'
      '  FROM DEINVOICE DI'
      'INNER JOIN DESERVICES DS ON DS.DEID = DI.DEID'
      
        'INNER JOIN DEINVITEMS DII ON DII.DIID = DI.DIID AND DII.SVID = D' +
        'S.SVID'
      'INNER JOIN SERVICES S ON S.SVID = DS.SVID'
      'INNER JOIN DEALS DE ON DE.DEID = DI.DEID'
      'INNER JOIN OFFICES OFSEND ON OFSEND.OFID = DE.DEOFIDSEND'
      'INNER JOIN OFFICES OFDEST ON OFDEST.OFID = DE.DEOFIDDEST'
      ' WHERE DI.DEID = :DEID'
      '       AND DS.DSPAYER ='
      '       CASE :Payer'
      '        WHEN 0 THEN 1098'
      '        WHEN 1 THEN 1099'
      '        WHEN 2 THEN 1100'
      '       END'
      '       AND S.SVID = 1'
      '       AND DII.DVTOTAL > 0.0'
      'UNION'
      'SELECT S.SVNAME AS Usluga,'
      '       (DII.DVTOTAL - DII.DVNDS) AS Cost,'
      
        '       DII.DVTOTAL AS Cost2, IIF ((DII.DVTOTAL - DII.DVNDS) > 0.' +
        '0, CAST(CAST((DII.DVNDS * 100.0) / (DII.DVTOTAL - DII.DVNDS) AS ' +
        'INTEGER)||'#39'%'#39' AS VARCHAR(3)), '#39'0%'#39') AS Stavka,'
      '       DII.DVNDS,  S.SVID'
      '  FROM DEINVOICE DI'
      'INNER JOIN DESERVICES DS ON DS.DEID = DI.DEID'
      
        'INNER JOIN DEINVITEMS DII ON DII.DIID = DI.DIID AND DII.SVID = D' +
        'S.SVID'
      'INNER JOIN SERVICES S ON S.SVID = DS.SVID'
      ' WHERE DI.DEID = :DEID'
      '       AND DS.DSPAYER ='
      '       CASE :Payer'
      '        WHEN 0 THEN 1098'
      '        WHEN 1 THEN 1099'
      '        WHEN 2 THEN 1100'
      '       END'
      '       AND S.SVID NOT IN (1,5)'
      '       AND DII.DVTOTAL > 0.0'
      'ORDER BY 6')
    Left = 424
    Top = 249
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
        Value = '17892'
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'Payer'
        ParamType = ptInput
        Value = '0'
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'Payer'
        ParamType = ptInput
      end>
  end
  object qActDetS: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      
        'SELECT CAST('#39#1054#1088#1075#1072#1085#1080#1079#1072#1094#1080#1103' '#1089#1090#1088#1072#1093#1086#1074#1072#1085#1080#1103' '#1075#1088#1091#1079#1072' '#1074' '#1047#1040#1054' "'#1043#1059#1058#1040' - '#1057#1090#1088#1072#1093#1086#1074 +
        #1072#1085#1080#1077'"'#39' AS VARCHAR(255)) USLUGA,'
      '       CAST(I.ICPREMIUM AS NUMERIC(15,2)) COST, CL.TYPETEXT,'
      '       CAST(0.0 AS NUMERIC(15,2)) NDS,'
      '       CAST(0.0 AS NUMERIC(15,2)) NSP'
      'FROM INSURANCE I'
      '   INNER JOIN CLIENTTYPE CL ON (CL.CLTYPE = I.ICPAYINSURANCE)'
      'WHERE I.DEID = :DEID'
      'AND CAST(I.ICPREMIUM AS NUMERIC(15,2)) > 0.0'
      'AND I.ICPAYINSURANCE = :PAYER')
    Left = 192
    Top = 337
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'Payer'
        ParamType = ptInput
      end>
  end
  object qKvitCRM: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT D.DEDEALNO,'
      '       CAST(D.DEDATEINSEND AS DATE) AS DEDATEINSEND1,'
      '       CAST(D.DEDATERECIPIENT AS DATE) AS DEDATERECIPIENT,'
      '       OS.OFTOWN AS punkt_otpr, OD.OFTOWN AS punkt_nazn,'
      
        '       COALESCE(CLSEND.CLLEGALNAME, CLSEND.CLNAME) AS otpravitel' +
        ', CLSEND.CLPHONEWAREHOUSE1 AS phone_otpr,'
      '       CLSEND.CLADDRESSWAREHOUSE AS adress_otpr,'
      
        '       (CASE WHEN T.TPPAYTRANSPORTATION = '#39'0'#39' THEN COALESCE(CLSE' +
        'ND.CLLEGALNAME, CLSEND.CLNAME) ELSE CRM.CTLEGALNAME END) AS klie' +
        'nt,'
      
        '       CRM.CTLEGALNAME AS poluchatel,CAST(('#39'('#39'||CRM.CTPHONEEXT||' +
        #39')'#39'||CRM.CTPHONE) AS VARCHAR(57)) AS phone_pol, CRM.CTLEGALADRES' +
        'S AS adress_pol,'
      
        '       (SELECT eks_name FROM EKSPEDITOR(:DEID)) AS eks_name, (SE' +
        'LECT eks_phone FROM EKSPEDITOR(:DEID)) as eks_phone,'
      '       (SELECT eks_adress FROM EKSPEDITOR(:DEID)) AS eks_adress,'
      '       T.TPGOODSDESCR AS xarakter_gr,'
      
        '       (CASE WHEN T.TPPAYTRANSPORTATION = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELS' +
        'E '#39#1087#1086#1083#1091#1095'.'#39' END) AS usl_transp,'
      '       CASE WHEN CA.CAPAYCAPTURE IS NOT NULL THEN'
      
        '       (CASE WHEN CA.CAPAYCAPTURE = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083 +
        #1091#1095'.'#39' END)'
      '       END  AS usl_zabor,'
      '       CASE WHEN DE.DVPAYDELIVERY IS NOT NULL THEN'
      
        '       (CASE WHEN DE.DVPAYDELIVERY = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086 +
        #1083#1091#1095'.'#39' END)'
      '       END  AS usl_dost,'
      '       (CASE WHEN PA.PTNAME <> '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080#39' THEN'
      
        '             (CASE WHEN T.TPPAYTRANSPORTATION = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074 +
        '.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' END) END)  AS usl_ju,'
      
        '       (CASE WHEN (T.TPVSTDSOFTPACK + T.TPVNOTSTDSOFTPACK) > 0.0' +
        '0 THEN'
      
        '             (CASE WHEN T.TPPAYTRANSPORTATION = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074 +
        '.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' END) END)  AS usl_mu,'
      '       CASE WHEN A.ASPAYER IS NOT NULL THEN'
      
        '       (CASE WHEN A.ASPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_plomb,'
      '       CASE WHEN I.IRPAYER IS NOT NULL THEN'
      
        '       (CASE WHEN I.IRPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_vnutrit,'
      
        '       CASE WHEN ((R.RTPAYER IS NOT NULL) AND (R.RTTYPE = 2)) TH' +
        'EN'
      
        '       (CASE WHEN R.RTPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_vozvr_torg12,'
      
        '       CASE WHEN ((R.RTPAYER IS NOT NULL) AND (R.RTTYPE = 1)) TH' +
        'EN'
      
        '       (CASE WHEN R.RTPAYER = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' E' +
        'ND)'
      '       END  AS usl_vozvr_email,'
      
        '       CASE WHEN (S.SS_S_PHONE IS NOT NULL) THEN (CASE WHEN T.TP' +
        'PAYTRANSPORTATION = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' END) END  A' +
        'S usl_sms_otpr,'
      
        '       CASE WHEN (S.SS_D_PHONE IS NOT NULL) THEN (CASE WHEN T.TP' +
        'PAYTRANSPORTATION = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087#1086#1083#1091#1095'.'#39' END) END  A' +
        'S usl_sms_poluch,'
      '       CASE WHEN IR.ICPAYINSURANCE IS NOT NULL THEN'
      
        '       (CASE WHEN IR.ICPAYINSURANCE = '#39'0'#39' THEN '#39#1086#1090#1087#1088#1072#1074'.'#39' ELSE '#39#1087 +
        #1086#1083#1091#1095'.'#39' END)'
      '       END  AS usl_strax,'
      
        '       T.TPDOPINF,  T.TPMARKING, T.TPSMALLPIECECNT, (T.TPSTDWEIG' +
        'HT + T.TPNOTSTDWEIGHT) AS ves,'
      '       (T.TPSTDVOLUME + T.TPNOTSTDVOLUME) AS volume,'
      '       A.ASSEALSCNT,'
      
        '       (CASE WHEN A.ASSEALSCNT IS NOT NULL THEN A.ASITEMS ELSE '#39 +
        #1053#1077' '#1091#1089#1090#1072#1085#1086#1074#1083#1077#1085#1099#39' END) AS nom_plomb,'
      
        '       OS.OFNAME AS gruz_prinyal,  IIF(:is21vek = 1,(SELECT eks_' +
        'name FROM EKSPEDITOR(:DEID)),OD.OFNAME) AS gruz_vydal,'
      '       T.TPTRANCPIECECNT, DE.DVPAYDELIVERY,'
      
        '       (CASE WHEN ((T.TPCONDPACK IS NULL) OR (T.TPCONDPACK = 0))' +
        ' THEN '#39#1042' '#1085#1086#1088#1084#1077#39
      '             WHEN T.TPCONDPACK = 1 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080#39
      '             WHEN T.TPCONDPACK = 2 THEN '#39#1053#1077#1085#1072#1076#1083#1077#1078#1072#1097#1072#1103#39
      '             WHEN T.TPCONDPACK = 3 THEN '#39#1055#1086#1074#1088#1077#1078#1076#1077#1085#1072#39
      
        '             WHEN T.TPCONDPACK = 4 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080' '#1080' '#1085#1077#1085#1072#1076#1083#1077#1078 +
        #1072#1097#1072#1103#39
      
        '             WHEN T.TPCONDPACK = 5 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082#1086#1074#1082#1080' '#1080' '#1087#1086#1074#1088#1077#1078#1076#1077 +
        #1085#1072#39
      
        '             WHEN T.TPCONDPACK = 6 THEN '#39#1055#1086#1074#1088#1077#1078#1076#1077#1085#1072' '#1080' '#1085#1077#1085#1072#1076#1083#1077#1078#1072#1097 +
        #1072#1103#39
      
        '             WHEN T.TPCONDPACK = 7 THEN '#39#1041#1077#1079' '#1091#1087#1072#1082'., '#1087#1086#1074#1088#1077#1078#1076#1077#1085#1072' '#1080 +
        ' '#1085#1077#1085#1072#1076#1083#1077#1078#1072#1097#1072#1103#39
      '        END) AS upak_klienta'
      'FROM DEALS D'
      'INNER JOIN TRANSPORTATION T ON T.DEID = D.DEID'
      'INNER JOIN CLIENTS CLSEND ON CLSEND.CLID = D.DECLIDSENDER'
      'INNER JOIN CLIENTS CLDEST ON CLDEST.CLID = D.DECLIDRECIPIENT'
      'INNER JOIN OFFICES OS ON OS.OFID = D.DEOFIDSEND'
      'INNER JOIN OFFICES OD ON OD.OFID = D.DEOFIDDEST'
      'LEFT OUTER JOIN CAPTURES CA ON CA.DEID = D.DEID'
      'LEFT OUTER JOIN DELIVERY DE ON DE.DEID = D.DEID'
      'LEFT OUTER JOIN PACKINGTYPES PA ON PA.PTID = T.PTID'
      'LEFT OUTER JOIN ADDSERVICE A ON A.DEID = D.DEID'
      'LEFT OUTER JOIN INTARE I ON I.DEID = D.DEID'
      'LEFT OUTER JOIN RETURNDOC R ON R.DEID = D.DEID'
      'LEFT OUTER JOIN SMS S ON S.DEID = D.DEID'
      'LEFT OUTER JOIN INSURANCE IR ON IR.DEID = D.DEID'
      
        'LEFT OUTER JOIN M_CUSTCROS MC ON MC.CLID = D.DECLIDRECIPIENT AND' +
        ' MC.OFID = :OFID'
      
        'LEFT OUTER JOIN M_CUSTOMER CRM ON CRM.CTID = MC.CTID AND CRM.OFI' +
        'D = :OFID'
      'WHERE D.DEID = :DEID'
      ''
      '')
    Left = 264
    Top = 361
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftUnknown
        Name = 'is21vek'
        ParamType = ptUnknown
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftUnknown
        Name = 'OFID'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'OFID'
        ParamType = ptUnknown
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end>
    object IBStringField5: TIBStringField
      FieldName = 'DEDEALNO'
      Origin = '"DEALS"."DEDEALNO"'
    end
    object IBStringField8: TIBStringField
      FieldName = 'PUNKT_OTPR'
      Origin = '"OFFICES"."OFTOWN"'
    end
    object IBStringField9: TIBStringField
      FieldName = 'PUNKT_NAZN'
      Origin = '"OFFICES"."OFTOWN"'
    end
    object IBStringField10: TIBStringField
      FieldName = 'OTPRAVITEL'
      Origin = '"CLIENTS"."CLNAME"'
      Size = 255
    end
    object IBStringField11: TIBStringField
      FieldName = 'PHONE_OTPR'
      Origin = '"CLIENTS"."CLPHONEWAREHOUSE1"'
    end
    object IBStringField12: TIBStringField
      FieldName = 'ADRESS_OTPR'
      Origin = '"CLIENTS"."CLADDRESSWAREHOUSE"'
      Size = 255
    end
    object IBStringField13: TIBStringField
      FieldName = 'KLIENT'
      Origin = '"CLIENTS"."CLNAME"'
      Size = 255
    end
    object IBStringField14: TIBStringField
      FieldName = 'POLUCHATEL'
      Origin = '"CLIENTS"."CLNAME"'
      Size = 255
    end
    object IBStringField17: TIBStringField
      FieldName = 'EKS_NAME'
      ProviderFlags = []
      Size = 255
    end
    object IBStringField18: TIBStringField
      FieldName = 'EKS_ADRESS'
      ProviderFlags = []
      Size = 255
    end
    object IBStringField19: TIBStringField
      FieldName = 'XARAKTER_GR'
      Origin = '"TRANSPORTATION"."TPGOODSDESCR"'
      Size = 255
    end
    object IBStringField20: TIBStringField
      FieldName = 'USL_TRANSP'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object IBStringField21: TIBStringField
      FieldName = 'USL_ZABOR'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object IBStringField22: TIBStringField
      FieldName = 'USL_DOST'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object IBStringField23: TIBStringField
      FieldName = 'USL_JU'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object IBStringField24: TIBStringField
      FieldName = 'USL_MU'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object IBStringField25: TIBStringField
      FieldName = 'USL_PLOMB'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object IBStringField26: TIBStringField
      FieldName = 'USL_VNUTRIT'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object IBStringField27: TIBStringField
      FieldName = 'USL_VOZVR_TORG12'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object IBStringField28: TIBStringField
      FieldName = 'USL_VOZVR_EMAIL'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object IBStringField29: TIBStringField
      FieldName = 'USL_SMS_OTPR'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object IBStringField30: TIBStringField
      FieldName = 'USL_SMS_POLUCH'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object IBStringField31: TIBStringField
      FieldName = 'USL_STRAX'
      ProviderFlags = []
      FixedChar = True
      Size = 7
    end
    object IBStringField32: TIBStringField
      FieldName = 'TPDOPINF'
      Origin = '"TRANSPORTATION"."TPDOPINF"'
      Size = 100
    end
    object IBStringField33: TIBStringField
      FieldName = 'TPMARKING'
      Origin = '"TRANSPORTATION"."TPMARKING"'
      Size = 30
    end
    object IntegerField2: TIntegerField
      FieldName = 'TPSMALLPIECECNT'
      Origin = '"TRANSPORTATION"."TPSMALLPIECECNT"'
    end
    object FloatField1: TFloatField
      FieldName = 'VES'
      ProviderFlags = []
    end
    object FloatField2: TFloatField
      FieldName = 'VOLUME'
      ProviderFlags = []
    end
    object IntegerField3: TIntegerField
      FieldName = 'ASSEALSCNT'
      Origin = '"ADDSERVICE"."ASSEALSCNT"'
    end
    object IBStringField34: TIBStringField
      FieldName = 'NOM_PLOMB'
      ProviderFlags = []
      Size = 100
    end
    object IBStringField35: TIBStringField
      FieldName = 'GRUZ_PRINYAL'
      Origin = '"OFFICES"."OFNAME"'
      Size = 80
    end
    object IBStringField36: TIBStringField
      FieldName = 'GRUZ_VYDAL'
      Origin = '"OFFICES"."OFNAME"'
      Size = 80
    end
    object IntegerField4: TIntegerField
      FieldName = 'TPTRANCPIECECNT'
      Origin = '"TRANSPORTATION"."TPTRANCPIECECNT"'
    end
    object IBStringField37: TIBStringField
      FieldName = 'DVPAYDELIVERY'
      Origin = '"DELIVERY"."DVPAYDELIVERY"'
      Size = 1
    end
    object IBStringField38: TIBStringField
      FieldName = 'EKS_PHONE'
      ProviderFlags = []
      Size = 255
    end
    object qKvitCRMDEDATEINSEND1: TDateField
      FieldName = 'DEDATEINSEND1'
      ProviderFlags = []
    end
    object qKvitCRMDEDATERECIPIENT: TDateField
      FieldName = 'DEDATERECIPIENT'
      ProviderFlags = []
    end
    object qKvitCRMADRESS_POL: TIBStringField
      FieldName = 'ADRESS_POL'
      Origin = '"M_CUSTOMER"."CTLEGALADRESS"'
      Size = 255
    end
    object qKvitCRMPHONE_POL: TIBStringField
      FieldName = 'PHONE_POL'
      ProviderFlags = []
      Size = 57
    end
    object qKvitCRMUPAK_KLIENTA: TIBStringField
      FieldName = 'UPAK_KLIENTA'
      ProviderFlags = []
      FixedChar = True
      Size = 36
    end
  end
  object qTicketCRM: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT D.DEID, CT.CTLEGALNAME CLNAME, O.OFNAME, D.DEDEALNO,'
      '       D.DEENTERED, D.DEDATEOUTDEST, D.DEWAYBILL, T.TPMARKING,'
      '       T.TPSMALLPIECECNT, T.TPTRANCPIECECNT, CL.STATUSTEXT,'
      '       T.TPGOODSDESCR, D.DEISINTARE'
      '  FROM CLIENTSTATUS CL'
      ' RIGHT OUTER JOIN CLIENTS C ON (CL.CLSTATUS = C.CLSTATUS)'
      ' RIGHT OUTER JOIN DEALS D ON (C.CLID = D.DECLIDRECIPIENT)'
      '  LEFT OUTER JOIN TRANSPORTATION T ON (D.DEID = T.DEID)'
      '  LEFT OUTER JOIN OFFICES O ON O.OFID = D.DEOFIDDEST'
      
        '  LEFT OUTER JOIN M_CUSTCROS CC ON (D.DECLIDRECIPIENT = CC.CLID)' +
        ' AND (CC.OFID = D.DEOFIDDEST)'
      
        '  LEFT OUTER JOIN M_CUSTOMER CT ON (CT.CTID = CC.CTID) AND (CT.O' +
        'FID = D.DEOFIDDEST)'
      ' WHERE D.DEID = :DEID')
    Left = 232
    Top = 361
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end>
  end
  object RvProject1: TRvProject
    Engine = RvSystem1
    ProjectFile = 'PrintDoc.rav'
    Left = 328
    Top = 8
  end
  object RvSystem1: TRvSystem
    TitleSetup = 'Output Options'
    TitleStatus = #1057#1090#1072#1090#1091#1089
    TitlePreview = 'Report Preview'
    SystemSetups = [ssAllowCopies, ssAllowCollate, ssAllowDuplex, ssAllowDestPreview, ssAllowDestPrinter, ssAllowDestFile, ssAllowPrinterSetup, ssAllowPreviewSetup]
    SystemFiler.StatusFormat = #1060#1086#1088#1084#1080#1088#1091#1102' '#1089#1090#1088#1072#1085#1080#1094#1091' %p'
    SystemPreview.FormState = wsMaximized
    SystemPreview.ShadowDepth = 5
    SystemPreview.ZoomFactor = 100.000000000000000000
    SystemPreview.ZoomInc = 25
    SystemPrinter.ScaleX = 100.000000000000000000
    SystemPrinter.ScaleY = 100.000000000000000000
    SystemPrinter.StatusFormat = 'Printing page %p'
    SystemPrinter.Title = 'ReportPrinter Report'
    SystemPrinter.Units = unMM
    SystemPrinter.UnitsFactor = 25.400000000000000000
    Left = 288
    Top = 8
  end
  object qMisc: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      
        'SELECT CAST('#39#1055#1072#1088#1072#1084#1077#1090#1088#1099' '#1075#1088#1091#1079#1072'. '#1042#1077#1089': '#39'||(G.DGSTDW + G.DGNSTDW)||'#39' ' +
        #1082#1075'. '#1054#1073#1098#1077#1084': '#39'||(G.DGSTDV + G.DGNSTDV)||'#39' '#1084'3 '#39'||'
      
        '         '#39#1054#1073#1098#1077#1084' '#1073#1077#1079' '#1046#1059': '#39'||(G.DGWOPACKSTDV + G.DGWOPACKNSTDV)||'#39 +
        ' '#1084'3 '#39'||'
      
        '         '#39#1054#1073#1098#1077#1084' '#1076#1083#1103' '#1091#1087#1072#1082#1086#1074#1082#1080' '#1074' '#1046#1059': '#39'||(G.DGFORPACKSTDV + G.DGFOR' +
        'PACKNSTDV)||'#39' '#1084'3 '#39'||'
      
        '         '#39#1054#1073#1098#1077#1084' '#1074' '#1046#1059': '#39'||(DP.DPPACKSTDV + DP.DPPACKNSTDV)||'#39' '#1084'3 ' +
        #39'||'
      
        '         '#39#1054#1073#1098#1077#1084' '#1074' '#1052#1059': '#39'||(DP.DPSOFTPACKSTDV + DP.DPSOFTPACKNSTDV' +
        ')||'#39' '#1084'3 '#39
      '         AS VARCHAR(1024)) AS misc, DII.SVID'
      'FROM DEINVOICE DI'
      
        '   INNER JOIN DEINVITEMS DII ON DII.DIID = DI.DIID AND DII.SVID ' +
        '= 1'
      '   INNER JOIN DEGOODS G ON G.DEID = :DEID'
      '   LEFT OUTER JOIN DEPACK DP ON DP.DEID = :DEID'
      'WHERE DI.DEID = :DEID'
      'UNION'
      
        'SELECT CAST('#39#1047#1072#1073#1086#1088' '#1075#1088#1091#1079#1072'. '#1058#1080#1087' '#1072#1074#1090#1086': '#39'||A.ATDESCRIPTION||'#39'. '#1054#1073#1083'. ' +
        #1079#1072#1073#1086#1088#1072' : '#39'||SD.SDNAME'
      '       AS VARCHAR(1024)) AS misc, DII.SVID'
      'FROM DEALS D'
      '   INNER JOIN CLIENTS C ON C.CLID ='
      '   CASE :Payer'
      '        WHEN 0 THEN D.DECLID_S'
      '        WHEN 1 THEN D.DECLID_R'
      '        WHEN 2 THEN D.DECLID_3'
      '   END'
      
        '   INNER JOIN DEINVOICE DI ON DI.DEID = D.DEID AND DI.CLID = C.C' +
        'LID'
      
        '   INNER JOIN DEINVITEMS DII ON DII.DIID = DI.DIID AND DII.SVID ' +
        '= 2'
      '   INNER JOIN DECAPTURES DC ON DC.DEID = D.DEID'
      '   INNER JOIN AUTOTYPES A ON A.ATID = DC.ATID'
      '   INNER JOIN SYS_DIC SD ON SD.SDID = DC.DCISTOWN'
      'WHERE D.DEID = :DEID'
      'UNION'
      
        'SELECT CAST('#39#1044#1086#1089#1090#1072#1074#1082#1072' '#1075#1088#1091#1079#1072'. '#1058#1080#1087' '#1072#1074#1090#1086': '#39'||A.ATDESCRIPTION||'#39'. '#1054#1073 +
        #1083'. '#1076#1086#1089#1090#1072#1074#1082#1080' : '#39'||SD.SDNAME'
      '       AS VARCHAR(1024)) AS misc, DII.SVID'
      'FROM DEALS D'
      '   INNER JOIN CLIENTS C ON C.CLID ='
      '   CASE :Payer'
      '        WHEN 0 THEN D.DECLID_S'
      '        WHEN 1 THEN D.DECLID_R'
      '        WHEN 2 THEN D.DECLID_3'
      '   END'
      
        '   INNER JOIN DEINVOICE DI ON DI.DEID = D.DEID AND DI.CLID = C.C' +
        'LID'
      
        '   INNER JOIN DEINVITEMS DII ON DII.DIID = DI.DIID AND DII.SVID ' +
        '= 3'
      '   INNER JOIN DEDELIVERY DV ON DV.DEID = D.DEID'
      '   INNER JOIN AUTOTYPES A ON A.ATID = DV.ATID'
      '   INNER JOIN SYS_DIC SD ON SD.SDID = DV.DDISTOWN'
      'WHERE D.DEID = :DEID'
      'UNION'
      
        'SELECT CAST('#39#1057#1090#1088#1072#1093#1086#1074#1072#1085#1080#1077' '#1075#1088#1091#1079#1072'. '#1042#1099#1075#1086#1076#1086#1087#1088#1080#1086#1073#1088#1077#1090#1072#1090#1077#1083#1100': '#39'||SD.SDNAM' +
        'E||'#39'. '#1054#1094#1077#1085#1086#1095#1085#1072#1103' '#1089#1090#1086#1080#1084#1086#1089#1090#1100' : '#39'||DEI.DIPRECOST||'#39' '#1088#1091#1073'.'#39
      '       AS VARCHAR(1024)) AS misc, DII.SVID'
      'FROM DEALS D'
      '   INNER JOIN CLIENTS C ON C.CLID ='
      '   CASE :Payer'
      '        WHEN 0 THEN D.DECLID_S'
      '        WHEN 1 THEN D.DECLID_R'
      '        WHEN 2 THEN D.DECLID_3'
      '   END'
      
        '   INNER JOIN DEINVOICE DI ON DI.DEID = D.DEID AND DI.CLID = C.C' +
        'LID'
      
        '   INNER JOIN DEINVITEMS DII ON DII.DIID = DI.DIID AND DII.SVID ' +
        '= 5'
      '   INNER JOIN DEINSURANCE DEI ON DEI.DEID = D.DEID'
      '   INNER JOIN SYS_DIC SD ON SD.SDID = DEI.DIINSGETTER'
      'WHERE D.DEID = :DEID'
      'UNION'
      
        'SELECT CAST('#39#1055#1083#1086#1084#1073#1080#1088#1086#1074#1082#1072' '#1075#1088#1091#1079#1072'. '#1058#1080#1087' '#1087#1083#1086#1084#1073': '#39'||SD.SDNAME||'#39'. '#1050#1086#1083#1080 +
        #1095#1077#1089#1090#1074#1086' : '#39'||DEP.DPCNT||'#39' '#1096#1090'.'#39
      '       ||'#39' '#1053#1086#1084#1077#1088#1072' '#1087#1083#1086#1084#1073' : '#39'||DEP.DPNUMBERS'
      '       AS VARCHAR(1024)) AS misc, DII.SVID'
      'FROM DEALS D'
      '   INNER JOIN CLIENTS C ON C.CLID ='
      '   CASE :Payer'
      '        WHEN 0 THEN D.DECLID_S'
      '        WHEN 1 THEN D.DECLID_R'
      '        WHEN 2 THEN D.DECLID_3'
      '   END'
      
        '   INNER JOIN DEINVOICE DI ON DI.DEID = D.DEID AND DI.CLID = C.C' +
        'LID'
      
        '   INNER JOIN DEINVITEMS DII ON DII.DIID = DI.DIID AND DII.SVID ' +
        '= 6'
      '   INNER JOIN DEPLOMBS DEP ON DEP.DEID = D.DEID'
      '   INNER JOIN SYS_DIC SD ON SD.SDID = DEP.DPPLOMBTYPE'
      'WHERE D.DEID = :DEID'
      'UNION'
      
        'SELECT CAST('#39#1042#1085#1091#1090#1088#1080#1090#1072#1088#1085#1072#1103' '#1087#1088#1080#1077#1084#1082#1072' '#1075#1088#1091#1079#1072'. '#1050#1086#1083#1080#1095#1077#1089#1090#1074#1086' '#1084#1077#1089#1090': '#39'||DEI' +
        '.DNCNT'
      '       AS VARCHAR(1024)) AS misc, DII.SVID'
      'FROM DEALS D'
      '   INNER JOIN CLIENTS C ON C.CLID ='
      '   CASE :Payer'
      '        WHEN 0 THEN D.DECLID_S'
      '        WHEN 1 THEN D.DECLID_R'
      '        WHEN 2 THEN D.DECLID_3'
      '   END'
      
        '   INNER JOIN DEINVOICE DI ON DI.DEID = D.DEID AND DI.CLID = C.C' +
        'LID'
      
        '   INNER JOIN DEINVITEMS DII ON DII.DIID = DI.DIID AND DII.SVID ' +
        '= 8'
      '   INNER JOIN DEINTARE DEI ON DEI.DEID = D.DEID'
      'WHERE D.DEID = :DEID'
      'UNION'
      'SELECT CAST('#39#1042#1086#1079#1074#1088#1072#1090' '#1076#1086#1082#1091#1084#1077#1085#1090#1086#1074'. '#1058#1080#1087': '#39'||SD.SDNAME'
      '       AS VARCHAR(1024)) AS misc, DII.SVID'
      'FROM DEALS D'
      '   INNER JOIN CLIENTS C ON C.CLID ='
      '   CASE :Payer'
      '        WHEN 0 THEN D.DECLID_S'
      '        WHEN 1 THEN D.DECLID_R'
      '        WHEN 2 THEN D.DECLID_3'
      '   END'
      
        '   INNER JOIN DEINVOICE DI ON DI.DEID = D.DEID AND DI.CLID = C.C' +
        'LID'
      
        '   INNER JOIN DEINVITEMS DII ON DII.DIID = DI.DIID AND DII.SVID ' +
        '= 7'
      '   INNER JOIN DERETDOCS DER ON DER.DEID = D.DEID'
      '   INNER JOIN SYS_DIC SD ON SD.SDID = DER.DRTYPE'
      'WHERE D.DEID = :DEID'
      'ORDER BY 2')
    Top = 241
    ParamData = <
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
        Value = '85443'
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftUnknown
        Name = 'Payer'
        ParamType = ptUnknown
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftUnknown
        Name = 'Payer'
        ParamType = ptUnknown
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftUnknown
        Name = 'Payer'
        ParamType = ptUnknown
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftUnknown
        Name = 'Payer'
        ParamType = ptUnknown
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftUnknown
        Name = 'Payer'
        ParamType = ptUnknown
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end
      item
        DataType = ftUnknown
        Name = 'Payer'
        ParamType = ptUnknown
      end
      item
        DataType = ftInteger
        Name = 'DEID'
        ParamType = ptInput
      end>
    object qMiscMISC: TIBStringField
      FieldName = 'MISC'
      ProviderFlags = []
      Size = 1024
    end
  end
  object rvdsInvMisc: TRvDataSetConnection
    LocalFilter = False
    RuntimeVisibility = rtEndUser
    DataSet = qMisc
    Top = 216
  end
end
